| Conditions | 3 |
| Paths | 4 |
| Total Lines | 16 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 21 | public function loadUserByUsername($username) |
||
| 22 | { |
||
| 23 | $queryParameters = array('email' => $username); |
||
| 24 | if ($this->entityReflection->implementsInterface('Majora\Framework\Model\EnablableInterface')) { |
||
| 25 | $queryParameters['enabled'] = true; |
||
| 26 | } |
||
| 27 | |||
| 28 | if (!$person = $this->retrieveOne($queryParameters)) { |
||
|
|
|||
| 29 | throw new UsernameNotFoundException(sprintf( |
||
| 30 | 'User "%s" is not an active person.', |
||
| 31 | $username |
||
| 32 | )); |
||
| 33 | } |
||
| 34 | |||
| 35 | return $person; |
||
| 36 | } |
||
| 37 | |||
| 61 |
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.