1 | <?php |
||
19 | abstract class AbstractApiClient implements ApiClientInterface |
||
20 | { |
||
21 | const MAX_RETRY_LIMIT = 3; |
||
22 | |||
23 | /** |
||
24 | * HTTP client. |
||
25 | * |
||
26 | * @var ClientInterface |
||
27 | */ |
||
28 | protected $client; |
||
29 | |||
30 | /** |
||
31 | * Authentication object. |
||
32 | * |
||
33 | * @var AuthenticationInterface |
||
34 | */ |
||
35 | protected $authenticator; |
||
36 | |||
37 | /** |
||
38 | * Retry attempt counter for authentication. |
||
39 | * |
||
40 | * @var int |
||
41 | */ |
||
42 | protected $authenticationRetryAttempt = 0; |
||
43 | |||
44 | /** |
||
45 | * {@inheritdoc} |
||
46 | */ |
||
47 | public function __construct( |
||
54 | |||
55 | /** |
||
56 | * Sets authentication retry limit to 0. |
||
57 | * |
||
58 | * @return void |
||
59 | */ |
||
60 | protected function resetAuthenticationRetryAttempt() |
||
66 | |||
67 | /** |
||
68 | * Increments the authentication retry attempt with 1. |
||
69 | * |
||
70 | * @return void |
||
71 | */ |
||
72 | protected function incrementAuthenticationRetryAttempt() |
||
78 | |||
79 | /** |
||
80 | * Returns authentication retry count. |
||
81 | * |
||
82 | * @return int |
||
83 | */ |
||
84 | public function getAuthenticationRetryAttempt() |
||
88 | |||
89 | /** |
||
90 | * Returns whether the authentication limit is reached. |
||
91 | * |
||
92 | * @return boolean |
||
93 | */ |
||
94 | protected function isAuthenticationRetryLimitReached() |
||
98 | } |
||
99 |