1 | <?php |
||
2 | |||
3 | /** |
||
4 | * MIT License |
||
5 | * For full license information, please view the LICENSE file that was distributed with this source code. |
||
6 | */ |
||
7 | |||
8 | namespace SprykerEco\Zed\AdyenApi\Business\Mapper; |
||
9 | |||
10 | use ArrayObject; |
||
11 | use Generated\Shared\Transfer\AdyenApiRequestTransfer; |
||
12 | use SprykerEco\Zed\AdyenApi\AdyenApiConfig; |
||
13 | |||
14 | abstract class AbstractMapper |
||
15 | { |
||
16 | /** |
||
17 | * @var \SprykerEco\Zed\AdyenApi\AdyenApiConfig |
||
18 | */ |
||
19 | protected $config; |
||
20 | |||
21 | /** |
||
22 | * @param \Generated\Shared\Transfer\AdyenApiRequestTransfer $adyenApiRequestTransfer |
||
23 | * |
||
24 | * @return void |
||
25 | */ |
||
26 | abstract protected function validateRequestTransfer(AdyenApiRequestTransfer $adyenApiRequestTransfer): void; |
||
27 | |||
28 | /** |
||
29 | * @param \SprykerEco\Zed\AdyenApi\AdyenApiConfig $config |
||
30 | */ |
||
31 | public function __construct(AdyenApiConfig $config) |
||
32 | { |
||
33 | $this->config = $config; |
||
34 | } |
||
35 | |||
36 | /** |
||
37 | * @param array $data |
||
38 | * |
||
39 | * @return array |
||
40 | */ |
||
41 | protected function removeRedundantParams(array $data): array |
||
42 | { |
||
43 | $data = array_filter($data, function ($item) { |
||
44 | if ($item instanceof ArrayObject) { |
||
45 | return $item->count() !== 0; |
||
46 | } |
||
47 | return !empty($item); |
||
48 | }); |
||
49 | |||
50 | foreach ($data as $key => $value) { |
||
51 | if (is_array($value) || $value instanceof ArrayObject) { |
||
52 | $data[$key] = $this->removeRedundantParams($value); |
||
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
53 | } |
||
54 | } |
||
55 | |||
56 | return $data; |
||
57 | } |
||
58 | } |
||
59 |