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.

ConfigReader   A
last analyzed

Complexity

Total Complexity 20

Size/Duplication

Total Lines 88
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 29
c 1
b 0
f 0
dl 0
loc 88
ccs 37
cts 37
cp 1
rs 10
wmc 20

9 Methods

Rating   Name   Duplication   Size   Complexity  
A getQueueNames() 0 6 1
A getPhpPath() 0 3 1
A specifyQueue() 0 9 3
A getSleep() 0 9 3
A getQueueConfig() 0 3 1
A getTimeout() 0 9 3
A getConnection() 0 9 3
A getAmount() 0 9 2
A getTries() 0 9 3
1
<?php
2
3
namespace Webparking\QueueEnsurer\Config;
4
5
class ConfigReader
6
{
7
    /** @return array<string> */
8 7
    public function getQueueNames(): array
9
    {
10
        /** @var array<string> $res */
11 7
        $res = array_keys(config('queue-ensurer.queues'));
12
13 7
        return $res;
14
    }
15
16 6
    public function getAmount(string $queueName): int
17
    {
18 6
        $queueConfig = $this->getQueueConfig($queueName);
19
20 6
        if (\is_array($queueConfig)) {
21 1
            return (int) $queueConfig['amount'];
22
        }
23
24 5
        return $queueConfig;
25
    }
26
27 3
    public function getPhpPath(): string
28
    {
29 3
        return config('queue-ensurer.php-path', 'php');
30
    }
31
32 3
    public function getConnection(string $queueName): ?string
33
    {
34 3
        $queueConfig = $this->getQueueConfig($queueName);
35
36 3
        if (\is_array($queueConfig) && \array_key_exists('connection', $queueConfig)) {
37 1
            return (string) $queueConfig['connection'];
38
        }
39
40 2
        return null;
41
    }
42
43 3
    public function specifyQueue(string $queueName): bool
44
    {
45 3
        $queueConfig = $this->getQueueConfig($queueName);
46
47 3
        if (\is_array($queueConfig) && \array_key_exists('specify-queue', $queueConfig)) {
48 1
            return (bool) $queueConfig['specify-queue'];
49
        }
50
51 2
        return config('queue-ensurer.defaults.specify-queue');
52
    }
53
54 3
    public function getTimeout(string $queueName): int
55
    {
56 3
        $queueConfig = $this->getQueueConfig($queueName);
57
58 3
        if (\is_array($queueConfig) && \array_key_exists('timeout', $queueConfig)) {
59 1
            return (int) $queueConfig['timeout'];
60
        }
61
62 2
        return config('queue-ensurer.defaults.timeout');
63
    }
64
65 3
    public function getSleep(string $queueName): int
66
    {
67 3
        $queueConfig = $this->getQueueConfig($queueName);
68
69 3
        if (\is_array($queueConfig) && \array_key_exists('sleep', $queueConfig)) {
70 1
            return (int) $queueConfig['sleep'];
71
        }
72
73 2
        return config('queue-ensurer.defaults.sleep');
74
    }
75
76 3
    public function getTries(string $queueName): int
77
    {
78 3
        $queueConfig = $this->getQueueConfig($queueName);
79
80 3
        if (\is_array($queueConfig) && \array_key_exists('tries', $queueConfig)) {
81 1
            return (int) $queueConfig['tries'];
82
        }
83
84 2
        return config('queue-ensurer.defaults.tries');
85
    }
86
87
    /**
88
     * @return array<string,int|string>|int
89
     */
90 6
    private function getQueueConfig(string $queueName)
91
    {
92 6
        return config('queue-ensurer.queues')[$queueName];
93
    }
94
}
95