Conditions | 5 |
Paths | 16 |
Total Lines | 20 |
Code Lines | 10 |
Lines | 0 |
Ratio | 0 % |
Tests | 14 |
CRAP Score | 5 |
Changes | 0 |
1 | <?php |
||
31 | 14 | public function setConfig(array $config, $columnName) |
|
32 | { |
||
33 | 14 | if (array_key_exists($columnName, $this->formTypes)) { |
|
34 | 4 | $config['form_type'] = $this->formTypes[$columnName]; |
|
35 | 4 | } |
|
36 | |||
37 | 14 | if (array_key_exists($columnName, $this->validationRules)) { |
|
38 | 4 | $config['validation'] = $this->validationRules[$columnName]; |
|
39 | 4 | } |
|
40 | |||
41 | 14 | if (array_key_exists($columnName, $this->functions)) { |
|
42 | 4 | $config['functions'] = $this->functions[$columnName]; |
|
43 | 4 | } |
|
44 | |||
45 | 14 | if (array_key_exists($columnName, $this->defaults)) { |
|
46 | 4 | $config['defaults'] = $this->defaults[$columnName]; |
|
47 | 4 | } |
|
48 | |||
49 | 14 | return $config; |
|
50 | } |
||
51 | } |
||
52 |
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.