| Total Complexity | 4 |
| Total Lines | 62 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Match |
||
| 8 | { |
||
| 9 | |||
| 10 | /** |
||
| 11 | * @var array |
||
| 12 | */ |
||
| 13 | protected $attributes; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * @var PatternRule |
||
| 17 | */ |
||
| 18 | protected $rule; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var bool |
||
| 22 | */ |
||
| 23 | protected $test; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * @param PatternRule $rule |
||
| 27 | * @param string $subject |
||
| 28 | */ |
||
| 29 | public function __construct(PatternRule $rule, string $subject) |
||
| 30 | { |
||
| 31 | $this->rule = $rule; |
||
| 32 | $result = \preg_match($this->regex(), $subject, $matches); |
||
| 33 | $this->test = $result !== 0; |
||
| 34 | $this->attributes = \array_filter( |
||
| 35 | $matches, |
||
| 36 | '\is_string', |
||
| 37 | \ARRAY_FILTER_USE_KEY |
||
| 38 | ); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return string |
||
| 43 | */ |
||
| 44 | protected function regex(): string |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return array |
||
| 57 | */ |
||
| 58 | public function getAttributes(): array |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * @return bool |
||
| 65 | */ |
||
| 66 | public function isTest(): bool |
||
| 69 | } |
||
| 70 | |||
| 72 |