Conditions | 2 |
Paths | 2 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 1 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
17 | public function testMemcached() |
||
18 | { |
||
19 | if (!class_exists('Memcached')) { |
||
20 | $this->markTestSkipped('The Memcached extension is not available.'); |
||
21 | return; |
||
22 | } |
||
23 | |||
24 | $client = new \Memcached; |
||
25 | $cache = new \Bouncer\Cache\Memcache(array('client' => $client)); |
||
26 | $bouncer = new \Bouncer\Bouncer(array('cache' => $cache)); |
||
27 | $this->assertInstanceOf('\\Bouncer\\Cache\\Memcache', $bouncer->getCache()); |
||
28 | $this->assertInstanceOf('\\Memcached', $bouncer->getCache()->getClient()); |
||
|
|||
29 | } |
||
30 | |||
32 |
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: