AbstractConcreteCompiler   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getPipeline() 0 4 1
A compile() 0 6 1
A process() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of UnderQuery package.
5
 *
6
 * Copyright (c) 2016 Beniamin Jonatan Šimko
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Phuria\UnderQuery\QueryCompiler\ConcreteCompiler;
13
14
use League\Pipeline\Pipeline;
15
use Phuria\UnderQuery\QueryBuilder\BuilderInterface;
16
use Phuria\UnderQuery\QueryCompiler\CompilerPayload;
17
18
/**
19
 * @author Beniamin Jonatan Šimko <[email protected]>
20
 */
21
abstract class AbstractConcreteCompiler implements ConcreteCompilerInterface
22
{
23
    /**
24
     * @var Pipeline
25
     */
26
    private $pipeline;
27
28
    /**
29
     * @param array $stages
30
     */
31
    public function __construct(array $stages)
32
    {
33
        $this->pipeline = new Pipeline($stages);
34
    }
35
36
    /**
37
     * @return Pipeline
38
     */
39
    public function getPipeline()
40
    {
41
        return $this->pipeline;
42
    }
43
44
    /**
45
     * @inheritdoc
46
     */
47
    public function compile(BuilderInterface $builder)
48
    {
49
        $payload = new CompilerPayload($builder);
50
51
        return $this->process($payload)->getActualSQL();
52
    }
53
54
    /**
55
     * @param CompilerPayload $payload
56
     *
57
     * @return CompilerPayload
58
     */
59
    private function process(CompilerPayload $payload)
60
    {
61
        return $this->getPipeline()->process($payload);
62
    }
63
}