| Conditions | 1 |
| Paths | 1 |
| Total Lines | 6 |
| Code Lines | 3 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 2 |
| Changes | 5 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | public function __invoke(Money $money, $showDecimals = null, $locale = null, $pattern = null) |
||
| 23 | { |
||
| 24 | $currencyFormat = $this->getView()->plugin('currencyFormat'); |
||
|
|
|||
| 25 | |||
| 26 | return $currencyFormat($money->getAmount() / 100, $money->getCurrency(), $showDecimals, $locale, $pattern); |
||
| 27 | } |
||
| 28 | } |
||
| 29 |
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: