Completed
Push — master ( 6c1975...f74146 )
by José
58s
created

DockerRegistryCatalogRepository::getAll()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
namespace Josepostiga\DockerRegistry\Repositories;
4
5
use Illuminate\Support\Collection;
6
use Josepostiga\DockerRegistry\Contracts\DockerRegistryClientInterface;
7
8
final class DockerRegistryCatalogRepository
9
{
10
    /**
11
     * @var DockerRegistryClientInterface
12
     */
13
    private $client;
14
15
    /**
16
     * DockerRegistryCatalogRepository constructor.
17
     *
18
     * @param DockerRegistryClientInterface $client
19
     */
20
    public function __construct(DockerRegistryClientInterface $client)
21
    {
22
        $this->client = $client;
23
    }
24
25
    /**
26
     * List all available repositories.
27
     *
28
     * @return Collection
29
     */
30
    public function list(): Collection
31
    {
32
        $request = $this->client->call('_catalog');
33
34
        $response = json_decode($request->getBody(), true);
35
36
        return new Collection($response['repositories']);
37
    }
38
}
39