| Conditions | 3 |
| Paths | 3 |
| Total Lines | 14 |
| Code Lines | 10 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 11 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 10 | 9 | private function parseMemberDocblock($member, Doc $doc = null) { |
|
| 11 | 9 | if ($doc !== null) { |
|
| 12 | 3 | $member->setDocblock($doc->getReformattedText()); |
|
| 13 | 3 | $docblock = $member->getDocblock(); |
|
| 14 | 3 | $member->setDescription($docblock->getShortDescription()); |
|
| 15 | 3 | $member->setLongDescription($docblock->getLongDescription()); |
|
| 16 | |||
| 17 | 3 | $vars = $docblock->getTags('var'); |
|
| 18 | 3 | if ($vars->size() > 0) { |
|
| 19 | 3 | $var = $vars->get(0); |
|
| 20 | 3 | $member->setType($var->getType(), $var->getDescription()); |
|
| 21 | } |
||
| 22 | } |
||
| 23 | 9 | } |
|
| 24 | |||
| 42 | } |
Let’s take a look at an example:
In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.
Available Fixes
Change the type-hint for the parameter:
Add an additional type-check:
Add the method to the interface: