Conditions | 8 |
Paths | 6 |
Total Lines | 20 |
Lines | 6 |
Ratio | 30 % |
Tests | 0 |
CRAP Score | 72 |
Changes | 0 |
1 | <?php |
||
22 | public static function validate(array $resource): array |
||
23 | { |
||
24 | if ($resource['data']['type'] === EndpointInterface::TYPE_SOURCE && (!is_array($resource['data']['options']['import']) || count($resource['data']['options']['import']) === 0)) { |
||
25 | throw new InvalidArgumentException('source endpoint must include at least one options.import attribute'); |
||
26 | } |
||
27 | |||
28 | if ($resource['data']['type'] === EndpointInterface::TYPE_DESTINATION && !isset($resource['data']['options']['filter_one'])) { |
||
29 | throw new InvalidArgumentException('destintation endpoint must have single object filter options.filter_one as a string'); |
||
30 | } |
||
31 | |||
32 | View Code Duplication | if (isset($resource['data']['options']['filter_one'])) { |
|
|
|||
33 | Helper::jsonDecode(stripslashes($resource['data']['options']['filter_one']), true); |
||
34 | } |
||
35 | |||
36 | View Code Duplication | if (isset($resource['data']['options']['filter_all'])) { |
|
37 | Helper::jsonDecode(stripslashes($resource['data']['options']['filter_all']), true); |
||
38 | } |
||
39 | |||
40 | return $resource; |
||
41 | } |
||
42 | } |
||
43 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.