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

IndexerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 49
Duplicated Lines 22.45 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 61.11%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 11
loc 49
ccs 11
cts 18
cp 0.6111
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 2
A build() 0 9 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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