Conditions | 7 |
Paths | 3 |
Total Lines | 24 |
Code Lines | 16 |
Lines | 14 |
Ratio | 58.33 % |
Tests | 19 |
CRAP Score | 7.2576 |
Changes | 0 |
1 | <?php |
||
48 | 18 | protected function fillGatewaySpecificFields($data) |
|
49 | { |
||
50 | 18 | $gateway = $this->getGateway(); |
|
51 | 18 | $gatewaySpecificFieldsData = $this->getGatewaySpecificFields(); |
|
52 | 18 | $gatewaySpecificFieldsConfig = Arr::get($this->gatewaySpecificFieldsConfig, $gateway); |
|
53 | 18 | if ($gatewaySpecificFieldsData && $gatewaySpecificFieldsConfig) { |
|
54 | 2 | View Code Duplication | foreach ($gatewaySpecificFieldsConfig['required'] as $field) { |
55 | 2 | $value = Arr::get($gatewaySpecificFieldsData, $field); |
|
56 | 2 | if (!is_null($value)) { |
|
57 | 2 | Arr::set($data, 'gateway_specific_fields.' . $gateway . '.' . $field, $value); |
|
58 | 2 | } else { |
|
59 | throw new InvalidRequestException("Missing gateway specific field: $field."); |
||
60 | } |
||
61 | 2 | } |
|
62 | 2 | View Code Duplication | foreach ($gatewaySpecificFieldsConfig['optional'] as $field) { |
63 | 2 | $value = Arr::get($gatewaySpecificFieldsData, $field); |
|
64 | 2 | if (!is_null($value)) { |
|
65 | 2 | Arr::set($data, 'gateway_specific_fields.' . $gateway . '.' . $field, $value); |
|
66 | 2 | } |
|
67 | 2 | } |
|
68 | 2 | } |
|
69 | |||
70 | 18 | return $data; |
|
71 | } |
||
72 | } |
||
73 |
This check looks for methods that are used by a trait but not required by it.
To illustrate, let’s look at the following code example
The trait
Idable
provides a methodequalsId
that in turn relies on the methodgetId()
. If this method does not exist on a class mixing in this trait, the method will fail.Adding the
getId()
as an abstract method to the trait will make sure it is available.