| Conditions | 1 |
| Paths | 1 |
| Total Lines | 17 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 14 | public function setUp() |
||
| 15 | { |
||
| 16 | $pwd = dirname(__FILE__); |
||
| 17 | |||
| 18 | $pathToFixture = sprintf('%s/Fixture/OffsetDateParserFixture.xml', $pwd); |
||
| 19 | |||
| 20 | $xml = simplexml_load_file($pathToFixture); |
||
| 21 | |||
| 22 | $pathToHeaderFixture = sprintf('%s/Fixture/OffsetDateParserHeaderFixture.xml', $pwd); |
||
| 23 | |||
| 24 | $xmlHeader = simplexml_load_file($pathToHeaderFixture); |
||
| 25 | |||
| 26 | $this->parser = new OffsetDateParser(); |
||
| 27 | |||
| 28 | $this->parser->setXmlField($xml); |
||
| 29 | $this->parser->setXmlHeader($xmlHeader); |
||
| 30 | } |
||
| 31 | |||
| 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 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: