| Total Complexity | 6 |
| Total Lines | 41 |
| Duplicated Lines | 0 % |
| Coverage | 93.75% |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 18 | class ExpressionStrategy extends AbstractConstraintStrategy |
||
| 19 | { |
||
| 20 | 1 | public function generateArguments(array $config): array |
|
| 21 | { |
||
| 22 | 1 | $parent = parent::generateArguments($config); |
|
| 23 | |||
| 24 | 1 | $parent['expression'] = $config['expression']; |
|
| 25 | |||
| 26 | 1 | $this->provideValues($parent, $config); |
|
| 27 | |||
| 28 | 1 | return $parent; |
|
| 29 | } |
||
| 30 | |||
| 31 | /** |
||
| 32 | * @param array<string, mixed> $args |
||
| 33 | * @param array<string, mixed> $config |
||
| 34 | * |
||
| 35 | * @return void |
||
| 36 | */ |
||
| 37 | 1 | protected function provideValues(array &$args, array $config): void |
|
| 38 | { |
||
| 39 | 1 | if (empty($config['variable'])) { |
|
| 40 | return; |
||
| 41 | } |
||
| 42 | |||
| 43 | 1 | $values = []; |
|
| 44 | 1 | foreach ($config['variable'] as $value) { |
|
| 45 | 1 | $values[$value['name']] = $this->sanitize($value['value']); |
|
| 46 | } |
||
| 47 | |||
| 48 | 1 | $args['values'] = $values; |
|
| 49 | } |
||
| 50 | |||
| 51 | 1 | protected function getValidatorProperty(): string |
|
| 52 | { |
||
| 53 | 1 | return 'expression'; |
|
| 54 | } |
||
| 55 | |||
| 56 | 1 | protected function getAttributeClassName(): string |
|
| 59 | } |
||
| 60 | } |
||
| 61 |