| Total Complexity | 6 |
| Total Lines | 45 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | abstract class AbstractRepository implements RuleRepository |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * Prepend a rule to all fields. Rules expressed as pipe-delimited strings will be converted to arrays. |
||
| 11 | * |
||
| 12 | * @param string $rule |
||
| 13 | * @param array $baseRules |
||
| 14 | * @return array[] |
||
| 15 | */ |
||
| 16 | protected function prependRule($rule, $baseRules) |
||
| 17 | { |
||
| 18 | 1 | return array_map(function ($ruleLine) use ($rule) { |
|
| 19 | 1 | return array_merge([$rule], $this->ensureArray($ruleLine)); |
|
| 20 | 1 | }, $baseRules); |
|
| 21 | } |
||
| 22 | |||
| 23 | /** |
||
| 24 | * Append a rule to all fields. Rules expressed as pipe-delimited strings will be converted to arrays. |
||
| 25 | * |
||
| 26 | * @param string $rule |
||
| 27 | * @param array $baseRules |
||
| 28 | * @return array[] |
||
| 29 | */ |
||
| 30 | protected function appendRule($rule, $baseRules) |
||
| 35 | } |
||
| 36 | |||
| 37 | /** |
||
| 38 | * Make sure the rules are expressed in array format. |
||
| 39 | * |
||
| 40 | * @param array|string|mixed $ruleLine |
||
| 41 | * @return array |
||
| 42 | */ |
||
| 43 | 2 | private function ensureArray($ruleLine) |
|
| 52 | } |
||
| 53 | } |
||
| 54 |