Passed
Push — master ( e3cdb6...cb4117 )
by Smoren
01:43
created

SchematorBuilder   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 9
c 1
b 0
f 0
dl 0
loc 26
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A withFilters() 0 6 2
A get() 0 3 1
A __construct() 0 3 1
A create() 0 4 1
1
<?php
2
3
namespace Smoren\Schemator\Factories;
4
5
use Smoren\Schemator\Components\Schemator;
6
use Smoren\Schemator\Interfaces\SchematorBuilderInterface;
7
use Smoren\Schemator\Interfaces\SchematorInterface;
8
9
class SchematorBuilder implements SchematorBuilderInterface
10
{
11
    protected SchematorInterface $schemator;
12
13
    public function __construct()
14
    {
15
        $this->create();
16
    }
17
18
    public function create(): SchematorBuilderInterface
19
    {
20
        $this->schemator = new Schemator();
21
        return $this;
22
    }
23
24
    public function withFilters(array $filters): SchematorBuilderInterface
25
    {
26
        foreach($filters as $filterName => $filter) {
27
            $this->schemator->addFilter($filterName, $filter);
28
        }
29
        return $this;
30
    }
31
32
    public function get(): SchematorInterface
33
    {
34
        return $this->schemator;
35
    }
36
}
37