| Conditions | 5 |
| Paths | 5 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 7 |
| CRAP Score | 5.2742 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 16 | public function addAll($items) |
||
| 17 | 1 | { |
|
| 18 | $this->validateTraversable($items); |
||
|
|
|||
| 19 | $isMap = $items instanceof MapInterface; |
||
| 20 | |||
| 21 | foreach ($items as $key => $value) { |
||
| 22 | if (is_array($value)) { |
||
| 23 | 2 | $value = new static($value); |
|
| 24 | } |
||
| 25 | 1 | ||
| 26 | 1 | if ($isMap && !$value instanceof Pair) { |
|
| 27 | 1 | $value = new Pair($key, $value); |
|
| 28 | } |
||
| 29 | |||
| 30 | 1 | $this->add($value); |
|
| 31 | } |
||
| 32 | 1 | } |
|
| 33 | |||
| 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
Idableprovides a methodequalsIdthat 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.