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

Password   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 47
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 47
c 1
b 0
f 0
wmc 6
lcom 1
cbo 2
ccs 16
cts 16
cp 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A addCriteria() 0 6 1
A generate() 0 4 1
A addFormat() 0 8 2
A __construct() 0 4 1
A score() 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 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