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.

SimilarNumber::hasSimilarity()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 0
Metric Value
cc 3
nc 3
nop 0
dl 0
loc 12
ccs 6
cts 6
cp 1
crap 3
rs 9.8666
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of gpupo/similarity
5
 * Created by Gilmar Pupo <[email protected]>
6
 * For the information of copyright and license you should read the file
7
 * LICENSE which is distributed with this source code.
8
 * Para a informação dos direitos autorais e de licença você deve ler o arquivo
9
 * LICENSE que é distribuído com este código-fonte.
10
 * Para obtener la información de los derechos de autor y la licencia debe leer
11
 * el archivo LICENSE que se distribuye con el código fuente.
12
 * For more information, see <https://www.gpupo.com/>.
13
 */
14
15
namespace Gpupo\Similarity;
16
17
class SimilarNumber extends SimilarityAbstract implements SimilarInterface
18
{
19 21
    public function hasSimilarity()
20
    {
21 21
        if ($this->isEquals()) {
22 8
            return true;
23
        }
24
25 13
        if ($this->isApproximate()) {
26 5
            return true;
27
        }
28
29 8
        return false;
30
    }
31
32 28
    public function isEquals()
33
    {
34 28
        if ($this->getInput()->getFirst() === $this->getInput()->getSecond()) {
35 15
            return true;
36
        }
37
38 13
        return false;
39
    }
40
41 21
    public function getProximityCalculation()
42
    {
43
        $calc = [
44 21
            'first'  => $this->getInput()->getFirst(),
45 21
            'second' => $this->getInput()->getSecond(),
46
        ];
47 21
        $calc['limit'] = $this->getLimitOfProximity($calc['first'], $calc['second']);
48 21
        $calc['difference'] = abs($calc['first'] - $calc['second']);
49
50 21
        return $calc;
51
    }
52
53 21
    protected function getLimitOfProximity($first, $second)
54
    {
55
        $calc = [
56 21
            'chars'         => strlen($first.$second),
57 21
            'multiplicator' => (10 - ($this->getAccuracy() / 10)),
58
        ];
59
60 21
        $calc['maxDifference'] = ($calc['chars'] * $calc['multiplicator']);
61
62 21
        return $calc;
63
    }
64
65 8
    public function __toArray()
66
    {
67 8
        return array_merge(parent::__toArray(), [
68 8
            'proximityCalculation' => $this->getProximityCalculation(),
69
        ]);
70
    }
71
}
72