Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 6 |
Lines | 14 |
Ratio | 100 % |
Tests | 6 |
CRAP Score | 2 |
Changes | 0 |
1 | <?php |
||
37 | 12 | public function isValid($value) |
|
38 | { |
||
39 | 12 | $result = $this->fetchResult($value); |
|
40 | |||
41 | // The following code will check if we have a valid result. In case of an empty array (we did not get a valid |
||
42 | // match) the not-operator will result to true, causing the error to be set. In case of a null value (no object |
||
43 | // has been found), the not-operator will also result to true. |
||
44 | 12 | if (!$result) { |
|
45 | 3 | $this->error(self::ERROR_NO_OBJECT_FOUND, $value); |
|
46 | 3 | return false; |
|
47 | } |
||
48 | |||
49 | 9 | return true; |
|
50 | } |
||
51 | } |
||
52 |
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.