| 1 | <?php |
||
| 20 | class RegexMatcher implements MatcherInterface |
||
| 21 | { |
||
| 22 | private $regex; |
||
| 23 | private $groups; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * RegexMatcher constructor. |
||
| 27 | * |
||
| 28 | * @param $regex |
||
| 29 | * @param array|null $groups |
||
| 30 | */ |
||
| 31 | 11 | public function __construct($regex, array $groups = [1 => null]) |
|
| 36 | |||
| 37 | /** |
||
| 38 | * Matches all occurrences and returns token list |
||
| 39 | * |
||
| 40 | * @param string $source Source to match tokens |
||
| 41 | * |
||
| 42 | * @param TokenFactoryInterface $factory |
||
| 43 | * |
||
| 44 | * @return \Generator |
||
| 45 | */ |
||
| 46 | 11 | public function match($source, TokenFactoryInterface $factory) |
|
| 63 | } |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.