Password   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 2
dl 0
loc 58
ccs 22
cts 22
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A addCriteria() 0 4 1
A addNamedCriteria() 0 6 1
A addFormat() 0 8 2
A score() 0 4 1
A passed() 0 4 1
A generate() 0 4 1
1
<?php
2
3
namespace DeGraciaMathieu\Riddler;
4
5
use DeGraciaMathieu\Riddler\Contracts;
6
7
class Password
8
{
9
10
    protected $criterias = [];
11
12
    protected $manager;
13
14 27
    public function __construct()
15
    {
16 27
        $this->manager = new Manager;
17 27
    }
18
19 26
    public function addCriteria(Contracts\Dictionary $dictionary, Contracts\Occurrence $occurrence)
20
    {
21 26
        $this->addNamedCriteria(null, $dictionary, $occurrence);
22 26
    }
23
24 26
    public function addNamedCriteria($name, Contracts\Dictionary $dictionary, Contracts\Occurrence $occurrence)
25
    {
26 26
        $buildCriteria = $this->manager->buildCriteria($name, $dictionary, $occurrence);
27
28 26
        $this->criterias[] = $buildCriteria;
29 26
    }
30
31 5
    public function addFormat(Contracts\Format $format)
32
    {
33 5
        $criteriasBundle = $format->handle();
34
35 5
        foreach ($criteriasBundle as $bundle) {
36 5
            $this->addCriteria($bundle[0], $bundle[1]);
37 5
        }
38 5
    }
39
40
    /**
41
     * Génère un nouveau mot de passe depuis les critères
42
     *
43
     * @return string
44
     */
45 13
    public function generate()
46
    {
47 13
        return $this->manager->generate($this->criterias);
48
    }
49
50
    /**
51
     * Evalue le mot de passe
52
     *
53
     * @return string
54
     */
55 10
    public function score($value)
56
    {
57 10
        return $this->manager->score($value, $this->criterias);
58
    }
59
60 4
    public function passed($value)
61
    {
62 4
        return $this->manager->passed($value, $this->criterias);
63
    }
64
}
65