Completed
Push — master ( 5f6191...cd27f7 )
by Changwan
02:35
created

SanitizerFactory   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 22
ccs 7
cts 7
cp 1
rs 10
c 0
b 0
f 0
wmc 4
lcom 1
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
A factory() 0 4 1
1
<?php
2
namespace Wandu\Sanitizer;
3
4
use Wandu\Sanitizer\Contracts\Rule;
5
use Wandu\Validator\TesterLoader;
6
use Wandu\Validator\ValidatorFactory;
7
8
class SanitizerFactory
9
{
10
    /** @var \Wandu\Validator\ValidatorFactory */
11
    protected $factory;
12
    
13 2
    public function __construct(TesterLoader $loader = null, SanitizerNormalizer $normalizer = null)
14
    {
15 2
        $this->factory = new ValidatorFactory(
16 2
            $loader ?: new TesterLoader(),
17 2
            $normalizer ?: new SanitizerNormalizer()
18
        );
19 2
    }
20
21
    /**
22
     * @param \Wandu\Sanitizer\Contracts\Rule $rule
23
     * @return \Wandu\Sanitizer\Sanitizer
24
     */
25 2
    public function factory(Rule $rule)
26
    {
27 2
        return new Sanitizer($rule, $this->factory->factory($rule->rule()));
28
    }
29
}
30