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.
Completed
Push — master ( c80709...02f185 )
by Rémi
19:02 queued 07:27
created

MajorityQuorum   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 0
dl 0
loc 38
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A init() 0 9 2
A isMet() 0 9 3
1
<?php
2
3
namespace RemiSan\Lock\Quorum;
4
5
use RemiSan\Lock\Quorum;
6
7
class MajorityQuorum implements Quorum
8
{
9
    /**
10
     * @var int
11
     */
12
    private $total;
13
14
    /**
15
     * @var int
16
     */
17
    private $quorum;
18
19
    /**
20
     * @inheritDoc
21
     */
22
    public function init($totalNumber)
23
    {
24
        if ($totalNumber < 1) {
25
            throw new \InvalidArgumentException();
26
        }
27
28
        $this->total = $totalNumber;
29
        $this->quorum = floor($totalNumber / 2) + 1;
0 ignored issues
show
Documentation Bug introduced by
The property $quorum was declared of type integer, but floor($totalNumber / 2) + 1 is of type double. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
30
    }
31
32
    /**
33
     * @inheritDoc
34
     */
35
    public function isMet($numberOfSuccess)
36
    {
37
        if ($numberOfSuccess < 0 ||
38
            $numberOfSuccess > $this->total) {
39
            throw new \InvalidArgumentException();
40
        }
41
42
        return $numberOfSuccess >= $this->quorum;
43
    }
44
}
45