Passed
Push — master ( 1ac390...22382b )
by DeGracia
02:33
created

Password   A

Complexity

Total Complexity 8

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 57
c 1
b 0
f 0
wmc 8
lcom 1
cbo 2
ccs 21
cts 21
cp 1
rs 10

7 Methods

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