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.

ApiClient::teams()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Pnz\MattermostClient;
6
7
use Http\Client\HttpClient;
8
use Http\Discovery\HttpClientDiscovery;
9
use Http\Discovery\MessageFactoryDiscovery;
10
use Http\Message\RequestFactory;
11
use Pnz\MattermostClient\Api\ChannelsApi;
12
use Pnz\MattermostClient\Api\FilesApi;
13
use Pnz\MattermostClient\Api\PostsApi;
14
use Pnz\MattermostClient\Api\TeamsApi;
15
use Pnz\MattermostClient\Api\UsersApi;
16
use Pnz\MattermostClient\Hydrator\Hydrator;
17
use Pnz\MattermostClient\Hydrator\ModelHydrator;
18
19
final class ApiClient
20
{
21
    /**
22
     * @var HttpClient
23
     */
24
    private $httpClient;
25
26
    /**
27
     * @var Hydrator
28
     */
29
    private $hydrator;
30
31
    /**
32
     * @var RequestFactory
33
     */
34
    private $requestFactory;
35
36
    /**
37
     * Construct an ApiClient instance.
38
     *
39
     * @param HttpClient|null     $httpClient     The HttpClient;  if null, the auto-discover will be used
40
     * @param RequestFactory|null $requestFactory The RequestFactory; if null, the auto-discover will be used
41
     * @param Hydrator|null       $hydrator       The Hydrator to use, default to the ModelHydrator
42
     */
43
    public function __construct(
44
        HttpClient $httpClient = null,
45
        RequestFactory $requestFactory = null,
46
        Hydrator $hydrator = null
47
    ) {
48
        $this->httpClient = $httpClient ?: HttpClientDiscovery::find();
49
        $this->requestFactory = $requestFactory ?: MessageFactoryDiscovery::find();
50
        $this->hydrator = $hydrator ?: new ModelHydrator();
51
    }
52
53
    /**
54
     * Returns configured ApiClient from the given Configurator, Hydrator and RequestFactory.
55
     *
56
     * @return ApiClient
57
     */
58
    public static function configure(
59
        HttpClientConfigurator $httpClientConfigurator,
60
        RequestFactory $requestFactory = null,
61
        Hydrator $hydrator = null
62
    ): self {
63
        $httpClient = $httpClientConfigurator->createConfiguredClient();
64
65
        return new self($httpClient, $requestFactory, $hydrator);
66
    }
67
68
    /**
69
     * Return a client handling the Users resources.
70
     *
71
     * @return Api\UsersApi
72
     */
73
    public function users(): UsersApi
74
    {
75
        return new Api\UsersApi($this->httpClient, $this->requestFactory, $this->hydrator);
76
    }
77
78
    /**
79
     * Return a client handling the Teams resources.
80
     *
81
     * @return Api\TeamsApi
82
     */
83
    public function teams(): TeamsApi
84
    {
85
        return new Api\TeamsApi($this->httpClient, $this->requestFactory, $this->hydrator);
86
    }
87
88
    /**
89
     * Return a client handling the Channels resources.
90
     *
91
     * @return Api\ChannelsApi
92
     */
93
    public function channels(): ChannelsApi
94
    {
95
        return new Api\ChannelsApi($this->httpClient, $this->requestFactory, $this->hydrator);
96
    }
97
98
    /**
99
     * Return a client handling the Posts resources.
100
     *
101
     * @return Api\PostsApi
102
     */
103
    public function posts(): PostsApi
104
    {
105
        return new Api\PostsApi($this->httpClient, $this->requestFactory, $this->hydrator);
106
    }
107
108
    /**
109
     * Return a client handling the Files resources.
110
     *
111
     * @return Api\FilesApi
112
     */
113
    public function files(): FilesApi
114
    {
115
        return new Api\FilesApi($this->httpClient, $this->requestFactory, $this->hydrator);
116
    }
117
}
118