| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 8 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 31 | 1 | protected function generateArray() |
|
| 32 | { |
||
| 33 | 1 | $result = []; |
|
| 34 | |||
| 35 | 1 | $last = count($this->items)-1; |
|
| 36 | |||
| 37 | 1 | for ($counter = 1; $counter <= $this->count; $counter++) { |
|
| 38 | 1 | $result[] = $this->items[$this->generateRandomInt(0, $last)]; |
|
|
|
|||
| 39 | } |
||
| 40 | |||
| 41 | 1 | if ($this->count == 1) { |
|
| 42 | 1 | return $result[0]; |
|
| 43 | } |
||
| 44 | |||
| 45 | 1 | return $result; |
|
| 46 | } |
||
| 47 | } |
||
| 48 |
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.