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.

Similarity::setMode()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
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
use Gpupo\Similarity\Input\InputNumber;
18
use Gpupo\Similarity\Input\InputString;
19
20
class Similarity extends SimilarityAbstract implements SimilarInterface
21
{
22
    const MODE_STRING = 'text';
23
24
    const MODE_NUMBER = 'number';
25
26
    protected $mode;
27
28
    protected $expert;
29
30 41
    protected function getMode()
31
    {
32 41
        if ($this->mode === self::MODE_NUMBER) {
33 21
            return self::MODE_NUMBER;
34
        }
35
36 20
        return self::MODE_STRING;
37
    }
38
39 41
    public function setMode($mode)
40
    {
41 41
        $this->mode = $mode;
42 41
        $this->expert = null;
43
44 41
        return $this;
45
    }
46
47 20 View Code Duplication
    public function setValues($a, $b)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
48
    {
49 20
        $input = new InputString($a, $b);
50 20
        $this->input = $input;
51
52 20
        $this->setMode(self::MODE_STRING);
53
54 20
        return $this;
55
    }
56
57 2
    public function setStopwords(array $list)
58
    {
59 2
        $this->getInput()->setStopwords($list);
60
61 2
        return $this;
62
    }
63
64 21 View Code Duplication
    public function setNumberValues($a, $b)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
65
    {
66 21
        $input = new InputNumber($a, $b);
67 21
        $this->input = $input;
68
69 21
        $this->setMode(self::MODE_NUMBER);
70
71 21
        return $this;
72
    }
73
74 41
    protected function getExpert()
75
    {
76 41
        if (!$this->expert) {
77 41
            $this->expert = $this->factoryExpert($this->getMode());
78
        }
79
80 41
        return $this->expert;
81
    }
82
83 41
    public function hasSimilarity()
84
    {
85 41
        return $this->getExpert()->hasSimilarity();
86
    }
87
88
    public function __toArray()
89
    {
90
        return  $this->getExpert()->__toArray();
91
    }
92
}
93