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.

UnanimousQuorum   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 0 Features 1
Metric Value
wmc 6
c 3
b 0
f 1
lcom 1
cbo 0
dl 0
loc 38
ccs 14
cts 14
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 8 2
A isMet() 0 15 4
1
<?php
2
3
namespace RemiSan\Lock\Quorum;
4
5
use RemiSan\Lock\Quorum;
6
7
class UnanimousQuorum implements Quorum
8
{
9
    /**
10
     * @var int
11
     */
12
    private $quorum = null;
13
14
    /**
15
     * {@inheritdoc}
16
     */
17 12
    public function init($totalNumber)
18
    {
19 12
        if ($totalNumber < 1) {
20 3
            throw new \InvalidArgumentException('You must have at least one store.');
21
        }
22
23 9
        $this->quorum = $totalNumber;
24 9
    }
25
26
    /**
27
     * {@inheritdoc}
28
     */
29 12
    public function isMet($numberOfSuccess)
30
    {
31 12
        if ($this->quorum === null) {
32 3
            throw new \RuntimeException('You must init the Quorum before querying it.');
33
        }
34
35 9
        if ($numberOfSuccess < 0 ||
36 9
            $numberOfSuccess > $this->quorum) {
37 6
            throw new \InvalidArgumentException(
38 2
                'Number of success cannot be inferior to zero or superior to the number of stores.'
39 4
            );
40
        }
41
42 3
        return $numberOfSuccess === $this->quorum;
43
    }
44
}
45