Conditions | 1 |
Paths | 1 |
Total Lines | 20 |
Code Lines | 17 |
Lines | 0 |
Ratio | 0 % |
Tests | 16 |
CRAP Score | 1 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
22 | 8 | public function getConfigTreeBuilder() |
|
23 | { |
||
24 | 8 | $treeBuilder = new TreeBuilder(); |
|
25 | 8 | $rootNode = $treeBuilder->root('mauro_moreno_find'); |
|
26 | $rootNode |
||
|
|||
27 | 8 | ->isRequired() |
|
28 | 8 | ->children() |
|
29 | 8 | ->scalarNode('find_directory_service') |
|
30 | 8 | ->isRequired() |
|
31 | 8 | ->end() |
|
32 | 8 | ->scalarNode('finder') |
|
33 | 8 | ->isRequired() |
|
34 | 8 | ->end() |
|
35 | 8 | ->scalarNode('lister') |
|
36 | 8 | ->isRequired() |
|
37 | 8 | ->end() |
|
38 | 8 | ->end(); |
|
39 | |||
40 | 8 | return $treeBuilder; |
|
41 | } |
||
42 | |||
44 |
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: