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

Password   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 37
c 0
b 0
f 0
wmc 6
lcom 1
cbo 2
rs 10

5 Methods

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