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.
Passed
Pull Request — master (#10)
by
unknown
04:43
created

ConfigReader   A

Complexity

Total Complexity 20

Size/Duplication

Total Lines 84
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 28
c 1
b 0
f 0
dl 0
loc 84
ccs 36
cts 36
cp 1
rs 10
wmc 20

9 Methods

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