1 | <?php |
||||
2 | |||||
3 | /* |
||||
4 | * This file is part of YaEtl |
||||
5 | * (c) Fabrice de Stefanis / https://github.com/fab2s/YaEtl |
||||
6 | * This source file is licensed under the MIT license which you will |
||||
7 | * find in the LICENSE file or at https://opensource.org/licenses/MIT |
||||
8 | */ |
||||
9 | |||||
10 | namespace fab2s\YaEtl\Transformers\Arrays; |
||||
11 | |||||
12 | use fab2s\NodalFlow\NodalFlowException; |
||||
13 | use fab2s\YaEtl\Transformers\TransformerAbstract; |
||||
14 | |||||
15 | class ArrayKeyTransformer extends TransformerAbstract |
||||
16 | { |
||||
17 | /** |
||||
18 | * Any callable with one argument which returns something |
||||
19 | * |
||||
20 | * @var callable |
||||
21 | */ |
||||
22 | protected $mapper; |
||||
23 | |||||
24 | /** |
||||
25 | * @param callable $mapper |
||||
26 | * |
||||
27 | * @throws NodalFlowException |
||||
28 | */ |
||||
29 | public function __construct(callable $mapper) |
||||
30 | { |
||||
31 | $this->mapper = $mapper; |
||||
32 | parent::__construct(); |
||||
33 | } |
||||
34 | |||||
35 | /** |
||||
36 | * Execute the array_map call |
||||
37 | * |
||||
38 | * @param array $param |
||||
39 | * |
||||
40 | * @return array |
||||
41 | */ |
||||
42 | public function exec($param = null) |
||||
43 | { |
||||
44 | return array_combine(array_map($this->mapper, array_keys($param)), array_values($param)); |
||||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
It seems like
$param can also be of type null ; however, parameter $array of array_values() does only seem to accept array , maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
45 | } |
||||
46 | } |
||||
47 |