GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Push — master ( 7642f8...15f213 )
by Jamie
07:09 queued 01:51
created

Service::listContainers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 5
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace OpenStack\ObjectStore\v1;
4
5
use OpenStack\Common\Error\BadResponseError;
6
use OpenStack\Common\Service\AbstractService;
7
use OpenStack\ObjectStore\v1\Models\Account;
8
use OpenStack\ObjectStore\v1\Models\Container;
9
10
/**
11
 * @property \OpenStack\ObjectStore\v1\Api $api
12
 */
13
class Service extends AbstractService
14
{
15
    /**
16
     * Retrieves an Account object.
17
     *
18
     * @return Account
19
     */
20 1
    public function getAccount()
21
    {
22 1
        return $this->model(Account::class);
23
    }
24
25
    /**
26
     * Retrieves a collection of container resources in a generator format.
27
     *
28
     * @param array         $options {@see \OpenStack\ObjectStore\v1\Api::getAccount}
29
     * @param callable|null $mapFn   Allows a function to be mapped over each element in the collection.
30
     *
31
     * @return \Generator
32
     */
33 1
    public function listContainers(array $options = [], callable $mapFn = null)
34
    {
35 1
        $options = array_merge($options, ['format' => 'json']);
36 1
        return $this->model(Container::class)->enumerate($this->api->getAccount(), $options, $mapFn);
37
    }
38
39
    /**
40
     * Retrieves a Container object and populates its name according to the value provided. Please note that the
41
     * remote API is not contacted.
42
     *
43
     * @param string $name The unique name of the container
44
     *
45
     * @return Container
46
     */
47 2
    public function getContainer($name = null)
48
    {
49 2
        return $this->model(Container::class, ['name' => $name]);
50
    }
51
52
    /**
53
     * Creates a new container according to the values provided.
54
     *
55
     * @param array $data {@see \OpenStack\ObjectStore\v1\Api::putContainer}
56
     *
57
     * @return Container
58
     */
59 2
    public function createContainer(array $data)
60
    {
61 2
        return $this->getContainer()->create($data);
62
    }
63
64
    /**
65
     * Checks the existence of a container.
66
     *
67
     * @param string $name The name of the container
68
     *
69
     * @return bool             TRUE if exists, FALSE if it doesn't
70
     * @throws BadResponseError Thrown for any non 404 status error
71
     */
72 4 View Code Duplication
    public function containerExists($name)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
73
    {
74
        try {
75 4
            $this->execute($this->api->headContainer(), ['name' => $name]);
76 1
            return true;
77 3
        } catch (BadResponseError $e) {
78 3
            if ($e->getResponse()->getStatusCode() === 404) {
79 2
                return false;
80
            }
81 1
            throw $e;
82
        }
83
    }
84
}
85