private PoHeader::tokenizeFormula($formula)
Tokenize the formula.
Parameters
string $formula: A string containing the arithmetic formula.
Return value
array List of arithmetic tokens identified in the formula.
File
- core/lib/Drupal/Component/Gettext/PoHeader.php, line 374
Class
- PoHeader
- Gettext PO header handler.
Namespace
Drupal\Component\Gettext
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 | private function tokenizeFormula( $formula ) { $formula = str_replace ( " " , "" , $formula ); $tokens = array (); for ( $i = 0; $i < strlen ( $formula ); $i ++) { if ( is_numeric ( $formula [ $i ])) { $num = $formula [ $i ]; $j = $i + 1; while ( $j < strlen ( $formula ) && is_numeric ( $formula [ $j ])) { $num .= $formula [ $j ]; $j ++; } $i = $j - 1; $tokens [] = $num ; } elseif ( $pos = strpos ( " =<>!&|" , $formula [ $i ])) { $next = $formula [ $i + 1]; switch ( $pos ) { case 1: case 2: case 3: case 4: if ( $next == '=' ) { $tokens [] = $formula [ $i ] . '=' ; $i ++; } else { $tokens [] = $formula [ $i ]; } break ; case 5: if ( $next == '&' ) { $tokens [] = '&&' ; $i ++; } else { $tokens [] = $formula [ $i ]; } break ; case 6: if ( $next == '|' ) { $tokens [] = '||' ; $i ++; } else { $tokens [] = $formula [ $i ]; } break ; } } else { $tokens [] = $formula [ $i ]; } } return $tokens ; } |
Please login to continue.