Completed
Push — master ( 0d5c20...3309bb )
by Changwan
09:19
created

ValidatorFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 2
A create() 0 4 1
1
<?php
2
namespace Wandu\Validator;
3
4
class ValidatorFactory
5
{
6
    /** @var \Wandu\Validator\TesterFactory */
7
    protected $tester;
8
    
9
    public function __construct(TesterFactory $tester = null)
10
    {
11
        if (!$tester) {
12
            $tester = new TesterFactory();
13
        }
14
        $this->tester = $tester;
15
    }
16
17
    /**
18
     * @param string|\Wandu\Validator\Contracts\Rule $rule
19
     * @return \Wandu\Validator\Validator
20
     */
21
    public function create($rule): Validator
22
    {
23
        return new Validator($this->tester, $rule);
24
    }
25
}
26