Passed
Push — master ( 9280cd...76fe10 )
by Simon
02:08
created

ReportQuery::get()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 9
Ratio 100 %

Importance

Changes 0
Metric Value
dl 9
loc 9
rs 9.6666
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
1
<?php
2
3
/*
4
 * This file is part of the ReportBundle package
5
 * 
6
 * (c) symball <http://simonball.me>
7
 * 
8
 * For the full copyright and license information, please view the LICENSE file 
9
 * that was distributed with this source code.
10
 */
11
12
namespace Symball\ReportBundle\Service;
13
14
use Symball\ReportBundle\Interfaces\QueryInterface;
15
16
/**
17
 * The report query service acts as a front-end for fetching query types
18
 * using a plug-in architecture
19
 *
20
 * @author Simon Ball <simonball at simonball dot me>
21
 */
22 View Code Duplication
class ReportQuery
0 ignored issues
show
Duplication introduced by
This class 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...
23
{
24
25
26
    private $queries = array();
27
28
    /**
29
     * Add an extra patter object to the stack for later use
30
     *
31
     * @param QueryInterface $query
32
     * @param string           $alias
33
     */
34
    public function addQuery(QueryInterface $query, $alias)
35
    {
36
        $this->queries[$alias] = $query;
37
    }
38
39
    /**
40
     * A front-end for running pattern operations that are loaded on to the stack
41
     *
42
     * @param string        $alias
43
     * @param ReportBuilder $context
0 ignored issues
show
Bug introduced by
There is no parameter named $context. 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...
44
     * @return boolean Success condition
45
     * @throws \Exception when pattern not available
46
     */
47
    public function get($alias)
48
    {
49
        if (isset($this->queries[$alias])) {
50
            
51
            return $this->queries[$alias];
52
        } else {
53
            throw new \Exception('Query type is not registered: ' . $alias);
54
        }
55
    }
56
57
    /**
58
     * Get a simple array list of the currently loaded pattern objects
59
     *
60
     * @return array
61
     */
62
    public function getQueriesLoaded()
63
    {
64
        return array_keys($this->queries);
65
    }
66
}
67