| Conditions | 6 |
| Paths | 6 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 42 |
| Changes | 0 | ||
| 1 | <?php |
||
| 23 | public static function validateWorkflow(array $resource): array |
||
| 24 | { |
||
| 25 | $resource = parent::validate($resource); |
||
|
|
|||
| 26 | $defaults = [ |
||
| 27 | 'data' => [ |
||
| 28 | 'ensure' => WorkflowInterface::ENSURE_LAST, |
||
| 29 | 'priority' => 0, |
||
| 30 | 'map' => [], |
||
| 31 | 'condition' => null, |
||
| 32 | ], |
||
| 33 | ]; |
||
| 34 | |||
| 35 | $resource = array_replace_recursive($defaults, $resource); |
||
| 36 | |||
| 37 | if (!isset($resource['data']['ensure']) || !in_array($resource['data']['ensure'], WorkflowInterface::VALID_ENSURES)) { |
||
| 38 | throw new InvalidArgumentException('data.ensure as string must be provided (one of exists,last,disabled,absent)'); |
||
| 39 | } |
||
| 40 | |||
| 41 | if (isset($resource['data']['condition'])) { |
||
| 42 | if (!is_string($resource['data']['condition'])) { |
||
| 43 | throw new InvalidArgumentException('provided data.condition must be a string'); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | if (!is_int($resource['data']['priority'])) { |
||
| 48 | throw new InvalidArgumentException('provided data.priority must be an integer'); |
||
| 49 | } |
||
| 50 | |||
| 51 | $resource['data']['map'] = AttributeMapValidator::validate($resource['data']['map']); |
||
| 52 | |||
| 53 | return $resource; |
||
| 54 | } |
||
| 55 | } |
||
| 56 |
This check looks for a call to a parent method whose name is different than the method from which it is called.
Consider the following code:
The
getFirstName()method in theSoncalls the wrong method in the parent class.