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 ( 27afaf...1c4da6 )
by Cees-Jan
01:36
created

AsyncClient   A

Complexity

Total Complexity 13

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 11

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 13
lcom 1
cbo 11
dl 0
loc 88
ccs 0
cts 54
cp 0
rs 10
c 0
b 0
f 0

13 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 7 1
A createFromClient() 0 4 1
A hydrate() 0 4 1
A extract() 0 4 1
A APIVersion() 0 4 1
A version() 0 4 1
A identification() 0 4 1
A state() 0 4 1
A pid() 0 4 1
A restart() 0 4 1
A shutdown() 0 4 1
A programs() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ApiClients\Client\Supervisord;
6
7
use ApiClients\Client\Supervisord\CommandBus\Command\APIVersionCommand;
8
use ApiClients\Client\Supervisord\CommandBus\Command\IdentificationCommand;
9
use ApiClients\Client\Supervisord\CommandBus\Command\PidCommand;
10
use ApiClients\Client\Supervisord\CommandBus\Command\ProgramsCommand;
11
use ApiClients\Client\Supervisord\CommandBus\Command\RestartCommand;
12
use ApiClients\Client\Supervisord\CommandBus\Command\ShutdownCommand;
13
use ApiClients\Client\Supervisord\CommandBus\Command\StateCommand;
14
use ApiClients\Client\Supervisord\CommandBus\Command\VersionCommand;
15
use ApiClients\Foundation\ClientInterface;
0 ignored issues
show
Bug introduced by
This use statement conflicts with another class in this namespace, ApiClients\Client\Supervisord\ClientInterface.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
16
use ApiClients\Foundation\Factory;
17
use ApiClients\Foundation\Resource\ResourceInterface;
18
use React\EventLoop\LoopInterface;
19
use React\Promise\CancellablePromiseInterface;
20
use Rx\Observable;
21
use function ApiClients\Tools\Rx\unwrapObservableFromPromise;
22
23
final class AsyncClient implements AsyncClientInterface
24
{
25
    /**
26
     * @var ClientInterface
27
     */
28
    private $client;
29
30
    /**
31
     * @param ClientInterface $client
32
     */
33
    private function __construct(ClientInterface $client)
34
    {
35
        $this->client = $client;
36
    }
37
38
    /**
39
     * @param  LoopInterface $loop
40
     * @param  array         $options
41
     * @return AsyncClient
42
     */
43
    public static function create(string $host, LoopInterface $loop, array $options = []): self
44
    {
45
        $options = ApiSettings::getOptions($host, $options, 'Async');
46
        $client = Factory::create($loop, $options);
47
48
        return new self($client);
49
    }
50
51
    /**
52
     * @internal
53
     * @param  ClientInterface $client
54
     * @return AsyncClient
55
     */
56
    public static function createFromClient(ClientInterface $client): self
57
    {
58
        return new self($client);
59
    }
60
61
    public function hydrate(string $resource): CancellablePromiseInterface
62
    {
63
        return $this->client->hydrate($resource);
64
    }
65
66
    public function extract(ResourceInterface $resource): CancellablePromiseInterface
67
    {
68
        return $this->client->extract($resource);
69
    }
70
71
    public function APIVersion(): CancellablePromiseInterface
72
    {
73
        return $this->client->handle(new APIVersionCommand());
74
    }
75
76
    public function version(): CancellablePromiseInterface
77
    {
78
        return $this->client->handle(new VersionCommand());
79
    }
80
81
    public function identification(): CancellablePromiseInterface
82
    {
83
        return $this->client->handle(new IdentificationCommand());
84
    }
85
86
    public function state(): CancellablePromiseInterface
87
    {
88
        return $this->client->handle(new StateCommand());
89
    }
90
91
    public function pid(): CancellablePromiseInterface
92
    {
93
        return $this->client->handle(new PidCommand());
94
    }
95
96
    public function restart(): CancellablePromiseInterface
97
    {
98
        return $this->client->handle(new RestartCommand());
99
    }
100
101
    public function shutdown(): CancellablePromiseInterface
102
    {
103
        return $this->client->handle(new ShutdownCommand());
104
    }
105
106
    public function programs(): Observable
107
    {
108
        return unwrapObservableFromPromise($this->client->handle(new ProgramsCommand()));
109
    }
110
}
111