Completed
Push — master ( dca6dc...178b4a )
by Richard
06:29
created

IndexerFactory   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 28.57%

Importance

Changes 5
Bugs 0 Features 1
Metric Value
wmc 3
c 5
b 0
f 1
lcom 1
cbo 2
dl 0
loc 42
ccs 4
cts 14
cp 0.2857
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A build() 0 12 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
     * @param   string      $project_root_path
0 ignored issues
show
Bug introduced by
There is no parameter named $project_root_path. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
37
     * @param   Schema[]    $schemas
38
     */
39 2
    public function __construct(Log $log, \PhpParser\Parser $parser, array $schemas) {
40 2
        $this->log = $log;
41 2
        $this->parser = $parser;
42
        $this->schemas = array_map(function(Schema $s) { return $s; }, $schemas);
43 2
    }
44
45
    /**
46
     * @return  Indexer
47
     */
48
    public function build(Insert $insert) {
49
        $indexer = new Indexer
50
            ( $this->log
51
            , $this->parser
52
            , $insert
53
            );
54
        foreach ($this->schemas as $schema) {
55
            assert('$schema instanceof \Lechimp\Dicto\Rules\Schema');
56
            $schema->register_listeners($indexer);
57
        }
58
        return $indexer;
59
    }
60
}
61