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.

ApiSettings::getOptions()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 14
ccs 6
cts 6
cp 1
rs 9.7998
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 1
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Client\Twitter;
4
5
use ApiClients\Foundation\Hydrator\Options as HydratorOptions;
6
use ApiClients\Foundation\Options;
7
use ApiClients\Foundation\Transport\Options as TransportOptions;
8
use ApiClients\Middleware\Json\JsonDecodeMiddleware;
9
use ApiClients\Middleware\Oauth1\Oauth1Middleware;
10
use ApiClients\Middleware\Oauth1\Options as Oauth1Options;
11
use ApiClients\Middleware\UserAgent\Options as UserAgentMiddlewareOptions;
12
use ApiClients\Middleware\UserAgent\UserAgentMiddleware;
13
use ApiClients\Middleware\UserAgent\UserAgentStrategies;
14
use ApiClients\Tools\Psr7\Oauth1\Definition;
15
16
final class ApiSettings
17
{
18
    const NAMESPACE = 'ApiClients\\Client\\Twitter\\Resource';
19
20
    const TRANSPORT_OPTIONS = [
21
        Options::HYDRATOR_OPTIONS => [
22
            HydratorOptions::NAMESPACE => self::NAMESPACE,
23
            HydratorOptions::NAMESPACE_DIR => __DIR__ . DIRECTORY_SEPARATOR . 'Resource' . DIRECTORY_SEPARATOR,
24
        ],
25
        Options::TRANSPORT_OPTIONS => [
26
            TransportOptions::HOST => 'api.twitter.com',
27
            TransportOptions::PATH => '/1.1/',
28
            TransportOptions::MIDDLEWARE => [
29
                Oauth1Middleware::class,
30
                JsonDecodeMiddleware::class,
31
                UserAgentMiddleware::class,
32
            ],
33
            TransportOptions::DEFAULT_REQUEST_OPTIONS => [
34
                UserAgentMiddleware::class => [
35
                    UserAgentMiddlewareOptions::STRATEGY => UserAgentStrategies::PACKAGE_VERSION,
36
                    UserAgentMiddlewareOptions::PACKAGE => 'api-clients/twitter',
37
                ],
38
            ],
39
        ],
40
    ];
41
42 2
    public static function getOptions(
43
        string $consumerKey,
44
        string $consumerSecret,
45
        string $suffix,
46
        array $suppliedOptions = []
47
    ): array {
48
        // @codingStandardsIgnoreStart
49 2
        $options = array_replace_recursive(self::TRANSPORT_OPTIONS, $suppliedOptions);
50 2
        $options[Options::HYDRATOR_OPTIONS][HydratorOptions::NAMESPACE_SUFFIX] = $suffix;
51 2
        $options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::CONSUMER_KEY] = new Definition\ConsumerKey($consumerKey);
52 2
        $options[Options::TRANSPORT_OPTIONS][TransportOptions::DEFAULT_REQUEST_OPTIONS][Oauth1Middleware::class][Oauth1Options::CONSUMER_SECRET] = new Definition\ConsumerSecret($consumerSecret);
53
        // @codingStandardsIgnoreEnd
54 2
        return $options;
55
    }
56
}
57