SchematorBuilder   A
last analyzed

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 withErrorsLevelMask() 0 4 1
A withPathDelimiter() 0 4 1
A withFilters() 0 6 2
A get() 0 3 1
A __construct() 0 3 1
A create() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Smoren\Schemator\Factories;
6
7
use Smoren\Schemator\Interfaces\BitmapInterface;
8
use Smoren\Schemator\Interfaces\SchematorBuilderInterface;
9
use Smoren\Schemator\Interfaces\SchematorInterface;
10
use Smoren\Schemator\Components\Schemator;
11
12
/**
13
 * Builder of Schemator object
14
 * @author Smoren <[email protected]>
15
 */
16
class SchematorBuilder implements SchematorBuilderInterface
17
{
18
    /**
19
     * @var Schemator Schemator object
20
     */
21
    protected SchematorInterface $schemator;
22
23
    /**
24
     * SchematorBuilder constructor.
25
     */
26
    public function __construct()
27
    {
28
        $this->create();
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34
    public function create(): SchematorBuilder
35
    {
36
        $this->schemator = new Schemator();
37
        return $this;
38
    }
39
40
    /**
41
     * @inheritDoc
42
     */
43
    public function withPathDelimiter(string $pathDelimiter): SchematorBuilder
44
    {
45
        $this->schemator->setPathDelimiter($pathDelimiter);
46
        return $this;
47
    }
48
49
    /**
50
     * @inheritDoc
51
     */
52
    public function withErrorsLevelMask(BitmapInterface $errorsLevelMask): SchematorBuilder
53
    {
54
        $this->schemator->setErrorsLevelMask($errorsLevelMask);
55
        return $this;
56
    }
57
58
    /**
59
     * @inheritDoc
60
     */
61
    public function withFilters(iterable $filters): SchematorBuilder
62
    {
63
        foreach ($filters as $filterName => $filter) {
64
            $this->schemator->addFilter($filterName, $filter);
65
        }
66
        return $this;
67
    }
68
69
    /**
70
     * @inheritDoc
71
     */
72
    public function get(): Schemator
73
    {
74
        return $this->schemator;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->schemator returns the type Smoren\Schemator\Interfaces\SchematorInterface which includes types incompatible with the type-hinted return Smoren\Schemator\Components\Schemator.
Loading history...
75
    }
76
}
77