| Conditions | 2 |
| Paths | 2 |
| Total Lines | 12 |
| Code Lines | 6 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 6 |
| Changes | 0 | ||
| 1 | <?php |
||
| 19 | public function __construct($wsdl, array $options = []) |
||
| 20 | {
|
||
| 21 | if (!array_key_exists('log_file', $options)) {
|
||
| 22 | throw new Exception("Debug soap client requires a log file path provided as \$options['log_file'] to work");
|
||
| 23 | } |
||
| 24 | |||
| 25 | $this->logFile = fopen($options['log_file'], "a"); |
||
| 26 | |||
| 27 | $options['trace'] = 1; |
||
| 28 | |||
| 29 | parent::__construct($wsdl, $options); |
||
|
|
|||
| 30 | } |
||
| 31 | |||
| 56 |
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: