| Conditions | 1 |
| Paths | 1 |
| Total Lines | 28 |
| Code Lines | 17 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 17 |
| CRAP Score | 1 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 12 | public function buildStates(array $types) |
||
| 13 | { |
||
| 14 | $getTypes = function ($tokenMask) use ($types) { |
||
| 15 | 19 | return array_filter($types, function ($type) use ($tokenMask) { |
|
| 16 | 19 | return $type & $tokenMask; |
|
| 17 | 19 | }); |
|
| 18 | 19 | }; |
|
| 19 | |||
| 20 | 19 | $any = new State($getTypes(State::S_ANY_TOKENS)); |
|
| 21 | 19 | $inQuote = new State($getTypes(State::S_IN_QUOTE_TOKENS)); |
|
| 22 | 19 | $inEscape = new State($getTypes(State::S_IN_ESCAPE_TOKENS)); |
|
| 23 | 19 | $inQuoteEscape = new State($getTypes(State::S_IN_QUOTE_ESCAPE_TOKENS)); |
|
| 24 | |||
| 25 | // generate state mapping |
||
| 26 | 19 | $any->addStateTarget(Token::T_ANY & ~Token::T_QUOTE & ~Token::T_ESCAPE, $any); |
|
| 27 | 19 | $any->addStateTarget(Token::T_QUOTE, $inQuote); |
|
| 28 | 19 | $any->addStateTarget(Token::T_ESCAPE, $inEscape); |
|
| 29 | |||
| 30 | 19 | $inQuote->addStateTarget(Token::T_CONTENT | Token::T_DOUBLE_QUOTE, $inQuote); |
|
| 31 | 19 | $inQuote->addStateTarget(Token::T_QUOTE, $any); |
|
| 32 | 19 | $inQuote->addStateTarget(Token::T_ESCAPE, $inQuoteEscape); |
|
| 33 | |||
| 34 | 19 | $inEscape->addStateTarget(Token::T_CONTENT, $any); |
|
| 35 | |||
| 36 | 19 | $inQuoteEscape->addStateTarget(Token::T_CONTENT, $inQuote); |
|
| 37 | |||
| 38 | 19 | return $any; |
|
| 39 | } |
||
| 40 | } |
||
| 41 |