Conditions | 2 |
Paths | 2 |
Total Lines | 14 |
Code Lines | 8 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 6 |
Changes | 3 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
17 | public function cloneCommand($command, $repository, $binary) |
||
18 | { |
||
19 | $cloneCommand = $command . ' clone '; |
||
20 | |||
21 | if ($this->environment->getSource()->getSubmodules()) { |
||
|
|||
22 | $cloneCommand .= ' --recursive'; |
||
23 | } |
||
24 | |||
25 | $cloneCommand .= ' -b ' . $this->environment->getSource()->getBranch(); |
||
26 | $cloneCommand .= ' "' . $repository . '"'; |
||
27 | $cloneCommand .= ' "' . $binary . '"'; |
||
28 | |||
29 | return $cloneCommand; |
||
30 | } |
||
31 | } |
||
32 |
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 sub-classes 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 parent class: