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

DockerRegistryCatalogRepository   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 31
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A list() 0 8 1
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