| Conditions | 3 |
| Paths | 3 |
| Total Lines | 20 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 6 |
| CRAP Score | 3.0261 |
| Changes | 0 | ||
| 1 | <?php |
||
| 28 | 92 | protected function createModel($data) |
|
| 29 | { |
||
| 30 | 92 | if (!empty($data['$err'])) |
|
| 31 | { |
||
| 32 | throw new ManganException(sprintf("There is an error in query: %s", $data['$err'])); |
||
| 33 | } |
||
| 34 | |||
| 35 | // By default create instances of same |
||
| 36 | // type as provided model |
||
| 37 | 92 | $model = $this->getModel(); |
|
|
|
|||
| 38 | |||
| 39 | // For non homogeneous collections class |
||
| 40 | // need to be taken from data, not defined |
||
| 41 | // by model |
||
| 42 | 92 | if(ManganMeta::create($model)->type()->homogenous === false) |
|
| 43 | { |
||
| 44 | 5 | $model = null; |
|
| 45 | } |
||
| 46 | 92 | return RawArray::toModel($data, $model); |
|
| 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.