Completed
Push — master ( b7ef6a...58a002 )
by Kirill
03:12
created

Builder   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 40%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 43
ccs 4
cts 10
cp 0.4
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A execute() 0 4 1
A nothing() 0 6 2
1
<?php
2
/**
3
 * This file is part of Hydrogen package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace RDS\Hydrogen\Processor\DatabaseProcessor;
11
12
use Doctrine\ORM\Mapping\ClassMetadata;
13
use RDS\Hydrogen\Processor\BuilderInterface;
14
use RDS\Hydrogen\Processor\ProcessorInterface;
15
use RDS\Hydrogen\Query;
16
17
/**
18
 * Class Builder
19
 */
20
abstract class Builder implements BuilderInterface
21
{
22
    /**
23
     * @var ProcessorInterface
24
     */
25
    protected $processor;
26
27
    /**
28
     * @var Query
29
     */
30
    protected $query;
31
32
    /**
33
     * Builder constructor.
34
     * @param Query $query
35
     * @param ProcessorInterface $processor
36
     */
37 30
    public function __construct(Query $query, ProcessorInterface $processor)
38
    {
39 30
        $this->processor = $processor;
40 30
        $this->query = $query;
41 30
    }
42
43
    /**
44
     * @param string $entity
45
     * @param Query $query
46
     * @return iterable
47
     */
48
    protected function execute(string $entity, Query $query): iterable
49
    {
50
        return $this->processor->getProcessor($entity)->getResult($query);
51
    }
52
53
    /**
54
     * @return \Generator
55
     */
56
    protected function nothing(): \Generator
57
    {
58
        if (false) {
59
            yield;
60
        }
61
    }
62
}
63