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

SchematorBuilder::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 2
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
nc 1
nop 0
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