Passed
Push — master ( 854f93...e973cc )
by DeGracia
01:46
created

Password::addFormat()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
3
namespace DeGraciaMathieu\Riddler;
4
5
use DeGraciaMathieu\Riddler\Contracts;
6
7
class Password {
8
9
    protected $criterias;
10
    protected $manager;
11
12 12
    public function __construct()
13
    {
14 12
        $this->criterias = [];
15 12
        $this->manager = new Manager;
16 12
    }
17
18 11
    public function addCriteria($dictionary, $occurence)
19
    {
20 11
        $buildCriteria = $this->manager->buildCriteria($dictionary, $occurence);
21
22 11
        $this->criterias[] = $buildCriteria;
23 11
    }   
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 12
    public function generate()
35
    {
36 12
        return $this->manager->generate($this->criterias);
37
    }	
38
}
39