| Conditions | 4 |
| Paths | 6 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 20 |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 49 | public function setCriteria($criteria) |
||
| 50 | { |
||
| 51 | if (is_array($criteria)) |
||
| 52 | { |
||
| 53 | $className = static::CriteriaClass; |
||
| 54 | $this->criteria = new $className($criteria); |
||
| 55 | } |
||
| 56 | elseif ($criteria instanceof CriteriaInterface) |
||
| 57 | { |
||
| 58 | $this->criteria = $criteria; |
||
| 59 | } |
||
| 60 | if ($this->criteria instanceof DecoratableInterface) |
||
| 61 | { |
||
| 62 | $this->criteria->decorateWith($this->getModel()); |
||
|
|
|||
| 63 | } |
||
| 64 | return $this; |
||
| 65 | } |
||
| 66 | |||
| 68 |
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.