Passed
Push — master ( 89de50...6aa9d5 )
by DeGracia
46s
created

Password::score()   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 13
    public function __construct()
14
    {
15 13
        $this->manager = new Manager;
16 13
    }
17
18 12
    public function addCriteria(Contracts\Dictionary $dictionary, Contracts\Occurrence $occurrence)
19
    {
20 12
        $buildCriteria = $this->manager->buildCriteria($dictionary, $occurrence);
21
22 12
        $this->criterias[] = $buildCriteria;
23 12
    }
24
25 5
    public function addFormat(Contracts\Format $format)
26
    {
27 5
        $criteriasBundle = $format->handle();
28
29 5
        foreach ($criteriasBundle as $bundle) {
30 5
            $this->addCriteria($bundle[0], $bundle[1]);
31
        }
32 5
    }
33
34
    /**
35
     * Génère un nouveau mot de passe depuis les critères
36
     *
37
     * @return string
38
     */
39 12
    public function generate()
40
    {
41 12
        return $this->manager->generate($this->criterias);
42
    }
43
44
    /**
45
     * Evalue le mot de passe
46
     *
47
     * @return string
48
     */
49 1
    public function score($value)
50
    {
51 1
        return $this->manager->score($value, $this->criterias);
52
    }
53
}
54