Conditions | 2 |
Paths | 1 |
Total Lines | 15 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php namespace Propaganistas\LaravelIntl\Base; |
||
13 | 15 | public function forLocale($locale, callable $callback, $fallbackLocale = '') |
|
14 | { |
||
15 | 10 | $original = $this->getLocale(); |
|
|
|||
16 | 10 | $fallback = $this->getFallbackLocale(); |
|
17 | |||
18 | 10 | $this->setLocale($locale); |
|
19 | 10 | $this->setFallbackLocale($fallbackLocale ?: $fallback); |
|
20 | |||
21 | 10 | $result = $callback($this); |
|
22 | |||
23 | 10 | $this->setLocale($original); |
|
24 | 10 | $this->setFallbackLocale($fallback); |
|
25 | |||
26 | 15 | return $result; |
|
27 | } |
||
28 | } |
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.