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