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

Password::passed()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 1
crap 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