Passed
Push — master ( 4c1109...779a6a )
by DeGracia
04:27
created

Password::subCriteria()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
namespace DeGraciaMathieu\Riddler;
4
5
use DeGraciaMathieu\Riddler\Contracts;
6
7
class Password {
8
9
    protected $criteriasAggregator;
10
    protected $manager;
11
12
    public function __construct()
13
    {
14
        $this->criteriasAggregator = [];
15
        $this->manager = new Manager;
16
    }
17
18
    public function addCriteria($criteria, $occurence = null)
19
    {
20
        $buildCriteria = $this->manager->buildCriteria($criteria, $occurence);
21
22
        $this->criteriasAggregator[] = $buildCriteria;
23
    }   
24
25
    public function subCriteria(Contracts\Criteria $subCriteria)
26
    {
27
        $this->criteriasAggregator = $this->manager->subCriteria($this->criteriasAggregator, $subCriteria);
28
    }
29
30
    public function addFormat(Contracts\Format $format)
31
    {
32
        $criteriasBundle = $format->handle();
33
34
        foreach ($criteriasBundle as $bundle) {
35
            $this->addCriteria($bundle[0], $bundle[1]);
36
        }
37
    }  
38
39
    public function generate()
40
    {
41
        return $this->manager->generate($this->criteriasAggregator);
42
    }	
43
}