| Conditions | 2 |
| Paths | 2 |
| Total Lines | 14 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 8 |
| CRAP Score | 2 |
| Changes | 0 | ||
| 1 | <?php |
||
| 44 | 5 | public function get(Destination $destination): Gateway |
|
| 45 | { |
||
| 46 | 5 | $destinationType = $destination->destinationType(); |
|
| 47 | 5 | if (!isset($this->gateways[$destinationType])) { |
|
| 48 | 1 | throw new InvalidArgumentException( |
|
| 49 | 1 | sprintf( |
|
| 50 | 1 | 'No gateway for destination type (%s) is supported.', |
|
| 51 | 1 | $destinationType |
|
| 52 | ) |
||
| 53 | ); |
||
| 54 | } |
||
| 55 | |||
| 56 | 4 | return $this->gateways[$destinationType]; |
|
| 57 | } |
||
| 58 | } |
||
| 59 |
Let’s assume you have a class which uses late-static binding:
The code above will run fine in your PHP runtime. However, if you now create a sub-class and call the
getSomeVariable()on that sub-class, you will receive a runtime error:In the case above, it makes sense to update
SomeClassto useselfinstead: