Conditions | 1 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Tests | 8 |
CRAP Score | 1 |
Changes | 0 |
1 | <?php |
||
38 | 1 | public function getDepth() |
|
39 | { |
||
40 | 1 | $max = 0; |
|
41 | $depth = function (&$max) { |
||
42 | 1 | return function($line) use (&$max) { |
|
43 | // every line-indent equals 4 spaces |
||
44 | 1 | $max = max([$max, (strlen($line) - strlen(ltrim($line))) / 4]); |
|
45 | 1 | }; |
|
46 | 1 | }; |
|
47 | |||
48 | // print_r returns formatted textual array presentation |
||
49 | 1 | array_map($depth($max), explode("\n", print_r($this->getValue(), true))); |
|
50 | // [1,2] -> 1, [3,4] -> 2, ..., [N,N+1] -> (N+1)/2 |
||
51 | 1 | return ceil(($max - 1) / 2) + 1; |
|
52 | } |
||
53 | |||
56 |
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
Idable
provides a methodequalsId
that 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.