Total Complexity | 5 |
Total Lines | 38 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
19 | final class MolliePluginLatestVersionChecker implements MolliePluginLatestVersionCheckerInterface |
||
20 | { |
||
21 | /** @var ClientInterface */ |
||
22 | private $client; |
||
23 | |||
24 | /** @var UriInterface */ |
||
25 | private $hubUri; |
||
26 | |||
27 | public function __construct( |
||
28 | ClientInterface $client, |
||
29 | string $hubUri |
||
30 | ) { |
||
31 | $this->client = $client; |
||
32 | $this->hubUri = new Uri($hubUri); |
||
33 | } |
||
34 | |||
35 | public function checkLatestVersion(): ?string |
||
36 | { |
||
37 | try { |
||
38 | $hubResponse = $this->client->request('GET', $this->hubUri); |
||
39 | } catch (GuzzleException $exception) { |
||
40 | return null; |
||
41 | } |
||
42 | |||
43 | $hubResponse = json_decode($hubResponse->getBody()->getContents(), true); |
||
44 | |||
45 | return $this->getMolliePluginLatestVersion($hubResponse); |
||
46 | } |
||
47 | |||
48 | private function getMolliePluginLatestVersion(array $data): ?string |
||
57 | } |
||
58 | } |
||
59 |