| Conditions | 4 |
| Paths | 4 |
| Total Lines | 25 |
| Code Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 15 |
| CRAP Score | 4.0039 |
| Changes | 8 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 47 | 7 | public function match($source, TokenFactoryInterface $factory) |
|
| 48 | { |
||
| 49 | 7 | preg_match_all($this->regex, $source, $matches, PREG_OFFSET_CAPTURE); |
|
| 50 | 7 | $matches = array_intersect_key($matches, $this->groups); |
|
| 51 | |||
| 52 | 7 | $result = []; |
|
| 53 | 7 | foreach ($matches as $id => $group) { |
|
| 54 | 7 | $name = $this->groups[$id]; |
|
| 55 | |||
| 56 | 7 | foreach ($group as $match) { |
|
| 57 | 7 | if ($match[1] === -1) { |
|
| 58 | continue; |
||
| 59 | } |
||
| 60 | |||
| 61 | /** @var Token $token */ |
||
| 62 | 7 | $token = $factory->create([$name, 'pos' => $match[1], 'length' => strlen($match[0])]); |
|
| 63 | |||
| 64 | 7 | $end = $token->getEnd(); |
|
| 65 | 7 | $result[spl_object_hash($token)] = $token; |
|
| 66 | 7 | $result[spl_object_hash($end)] = $end; |
|
| 67 | 7 | } |
|
| 68 | 7 | } |
|
| 69 | |||
| 70 | 7 | return $result; |
|
| 71 | } |
||
| 72 | } |