Conditions | 4 |
Paths | 3 |
Total Lines | 16 |
Lines | 0 |
Ratio | 0 % |
Tests | 11 |
CRAP Score | 4 |
Changes | 0 |
1 | <?php namespace Arcanedev\Composer\Entities\PackageTraits; |
||
30 | 99 | protected function mergeScripts(RootPackageInterface $root, PluginState $state) |
|
31 | { |
||
32 | 99 | $scripts = $this->getPackage()->getScripts(); |
|
33 | |||
34 | 99 | if ( ! $state->shouldMergeScripts() || empty($scripts)) |
|
35 | 87 | return; |
|
36 | |||
37 | 12 | $rootScripts = $root->getScripts(); |
|
38 | |||
39 | 12 | $scripts = $state->replaceDuplicateLinks() |
|
40 | 3 | ? array_merge($rootScripts, $scripts) |
|
41 | 12 | : array_merge($scripts, $rootScripts); |
|
42 | |||
43 | 12 | self::unwrapIfNeeded($root, 'setScripts') |
|
|
|||
44 | 12 | ->setScripts($scripts); |
|
45 | 12 | } |
|
46 | } |
||
47 |
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: