Completed
Push — master ( 605cf4...2dcac2 )
by Richard
05:16
created

IndexerFactory::__construct()   A

Complexity

Conditions 2
Paths 1

Size

Total Lines 11
Code Lines 9

Duplication

Lines 11
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
dl 11
loc 11
ccs 11
cts 11
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 9
nc 1
nop 3
crap 2
1
<?php
2
/******************************************************************************
3
 * An implementation of dicto (scg.unibe.ch/dicto) in and for PHP.
4
 *
5
 * Copyright (c) 2016, 2015 Richard Klees <[email protected]>
6
 *
7
 * This software is licensed under The MIT License. You should have received
8
 * a copy of the license along with the code.
9
 */
10
11
namespace Lechimp\Dicto\Indexer;
12
13
use Lechimp\Dicto\Rules\Schema;
14
use Psr\Log\LoggerInterface as Log;
15
16
/**
17
 * Creates Indexers.
18
 */
19
class IndexerFactory {
20
    /**
21
     * @var Log
22
     */
23
    protected $log;
24
25
    /**
26
     * @var \PhpParser\Parser
27
     */
28
    protected $parser;
29
30
    /**
31
     * @var Schema[]
32
     */
33
    protected $schemas;
34
35
    /**
36
     * @var ASTVisitor[]
37
     */
38
    protected $ast_visitors;
39
40
    /**
41
     * @param   Schema[]    $schemas
42
     */
43 2 View Code Duplication
    public function __construct(Log $log, \PhpParser\Parser $parser, array $schemas) {
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
44 2
        $this->log = $log;
45 2
        $this->parser = $parser;
46 2
        $this->ast_visitors = [];
47 2
        $this->schemas = array_map(function(Schema $s) {
48 2
            if ($s instanceof ASTVisitor) {
49 2
                $this->ast_visitors[] = $s;
50 2
            }
51 2
            return $s;
52 2
        }, $schemas);
53 2
    }
54
55
    /**
56
     * @return  Indexer
57
     */
58
    public function build(Insert $insert) {
59
        $indexer = new Indexer
60
            ( $this->log
61
            , $this->parser
62
            , $insert
63
            , $this->ast_visitors
64
            );
65
        return $indexer;
66
    }
67
}
68