| Conditions | 5 |
| Paths | 5 |
| Total Lines | 19 |
| Code Lines | 12 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 30 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 134 | public function slice($start, $length) |
||
| 135 | { |
||
| 136 | $res = new static(); |
||
| 137 | if ($length <= 0) { |
||
| 138 | return $res; |
||
| 139 | } |
||
| 140 | foreach ($this as $v) { |
||
| 141 | if ($start !== 0) { |
||
| 142 | --$start; |
||
| 143 | continue; |
||
| 144 | } |
||
| 145 | $res[] = $v; |
||
| 146 | if (--$length === 0) { |
||
| 147 | break; |
||
| 148 | } |
||
| 149 | } |
||
| 150 | |||
| 151 | return $res; |
||
| 152 | } |
||
| 153 | |||
| 221 |
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.