Conditions | 4 |
Paths | 6 |
Total Lines | 12 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 20 |
Changes | 0 |
1 | <?php |
||
21 | public function previous($fallback = false) |
||
22 | { |
||
23 | $referrer = $this->getContext()->getHeaders()->get('referer'); |
||
24 | $url = $referrer ? $this->to($referrer) : $this->getPreviousUrlFromSession(); |
||
|
|||
25 | if ($url) { |
||
26 | return $url; |
||
27 | } elseif ($fallback) { |
||
28 | return $this->to($fallback); |
||
29 | } else { |
||
30 | return $this->to('/'); |
||
31 | } |
||
32 | } |
||
33 | |||
46 | } |
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.