1 | <?php |
||
30 | final class RetrialQueueThrottler implements ThrottlerInterface |
||
31 | { |
||
32 | /** |
||
33 | * @var ThrottlerInterface |
||
34 | */ |
||
35 | private $internalThrottler; |
||
36 | |||
37 | /** |
||
38 | * @var TimeAdapterInterface |
||
39 | */ |
||
40 | private $timeProvider; |
||
41 | |||
42 | /** |
||
43 | * @param RetriableThrottlerInterface $internalThrottler |
||
44 | * @param TimeAdapterInterface $timeProvider |
||
45 | */ |
||
46 | 12 | public function __construct(RetriableThrottlerInterface $internalThrottler, TimeAdapterInterface $timeProvider) |
|
51 | |||
52 | /** |
||
53 | * @inheritdoc |
||
54 | */ |
||
55 | 3 | public function access() |
|
62 | |||
63 | /** |
||
64 | * @inheritdoc |
||
65 | */ |
||
66 | 8 | public function hit() |
|
74 | |||
75 | /** |
||
76 | * @inheritdoc |
||
77 | */ |
||
78 | 2 | public function clear() |
|
82 | |||
83 | /** |
||
84 | * @inheritdoc |
||
85 | */ |
||
86 | 3 | public function count() |
|
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | 6 | public function check() |
|
98 | |||
99 | /** |
||
100 | * @inheritdoc |
||
101 | */ |
||
102 | public function getTime() |
||
106 | |||
107 | /** |
||
108 | * @inheritdoc |
||
109 | */ |
||
110 | public function getLimit() |
||
114 | } |
||
115 |
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: