RegistryClient   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 19
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getImageTagsOnDockerHub() 0 12 1
1
<?php
2
3
namespace TheAentMachine\Registry;
4
5
use GuzzleHttp\Client;
6
7
class RegistryClient
8
{
9
    /**
10
     * Returns the list of tags available for an image stored on Docker Hub.
11
     *
12
     * @return string[]
13
     */
14
    public function getImageTagsOnDockerHub(string $image): array
15
    {
16
        $client = new Client();
17
        $res = $client->request('GET', 'https://registry.hub.docker.com/v1/repositories/' . $image . '/tags');
18
19
        $response = \GuzzleHttp\json_decode($res->getBody(), true);
20
21
        $tags = \array_map(function (array $item) {
22
            return $item['name'];
23
        }, $response);
24
25
        return $tags;
26
    }
27
}
28