Passed
Push — master ( 92dc8b...8279be )
by Smoren
01:43
created

SchematorBuilder   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 7
eloc 13
c 1
b 0
f 0
dl 0
loc 59
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A create() 0 4 1
A withErrorsLevelMask() 0 4 1
A withPathDelimiter() 0 4 1
A withFilters() 0 6 2
A get() 0 3 1
1
<?php
2
3
namespace Smoren\Schemator\Factories;
4
5
use Smoren\Schemator\Interfaces\SchematorBuilderInterface;
6
use Smoren\Schemator\Interfaces\SchematorInterface;
7
use Smoren\Schemator\Components\Schemator;
8
9
/**
10
 * Builder of Schemator object
11
 * @author Smoren <[email protected]>
12
 */
13
class SchematorBuilder implements SchematorBuilderInterface
14
{
15
    /**
16
     * @var SchematorInterface Schemator object
17
     */
18
    protected SchematorInterface $schemator;
19
20
    /**
21
     * SchematorBuilder constructor.
22
     */
23
    public function __construct()
24
    {
25
        $this->create();
26
    }
27
28
    /**
29
     * @inheritDoc
30
     */
31
    public function create(): SchematorBuilderInterface
32
    {
33
        $this->schemator = new Schemator();
34
        return $this;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function withPathDelimiter(string $pathDelimiter): SchematorBuilderInterface
41
    {
42
        $this->schemator->setPathDelimiter($pathDelimiter);
43
        return $this;
44
    }
45
46
    /**
47
     * @inheritDoc
48
     */
49
    public function withErrorsLevelMask(int $errorsLevelMask): SchematorBuilderInterface
50
    {
51
        $this->schemator->setErrorsLevelMask($errorsLevelMask);
52
        return $this;
53
    }
54
55
    /**
56
     * @inheritDoc
57
     */
58
    public function withFilters(iterable $filters): SchematorBuilderInterface
59
    {
60
        foreach($filters as $filterName => $filter) {
61
            $this->schemator->addFilter($filterName, $filter);
62
        }
63
        return $this;
64
    }
65
66
    /**
67
     * @inheritDoc
68
     */
69
    public function get(): SchematorInterface
70
    {
71
        return $this->schemator;
72
    }
73
}
74