Total Complexity | 2 |
Total Lines | 32 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
5 | trait InteractsWithInputPath |
||
6 | { |
||
7 | /** |
||
8 | * Searches in the $input array for the key bu the $path, and then |
||
9 | * prepend the $values in front of that key. |
||
10 | * |
||
11 | * @param array $input |
||
12 | * @param string $path |
||
13 | * @param array $values |
||
14 | * @return array |
||
15 | */ |
||
16 | protected static function mergeBeforePathInput(array $input, string $path, array $values = []): array |
||
17 | { |
||
18 | $key = array_search($path, $input) - 1; |
||
19 | |||
20 | return static::mergeBeforeKey($input, $key, $values); |
||
21 | } |
||
22 | |||
23 | /** |
||
24 | * Prepend the given $values in front of the $key in $input. |
||
25 | * |
||
26 | * @param array $input |
||
27 | * @param integer $key |
||
28 | * @param array $values |
||
29 | * @return array |
||
30 | */ |
||
31 | protected static function mergeBeforeKey(array $input, int $key, array $values = []): array |
||
37 | ); |
||
38 | } |
||
40 |