DataSourceChain   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 6
c 0
b 0
f 0
lcom 1
cbo 0
dl 0
loc 58
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDataSources() 0 4 1
A addDataSource() 0 12 1
A getData() 0 4 1
A getDataSource() 0 4 1
A getDataSourceParameters() 0 4 1
1
<?php
2
3
namespace Victoire\Bundle\CriteriaBundle\Chain;
4
5
/**
6
 * DataSource chain.
7
 */
8
class DataSourceChain
9
{
10
    private $dataSource;
11
12
    public function __construct()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
13
    {
14
        $this->dataSource = [];
15
    }
16
17
    /**
0 ignored issues
show
introduced by
Doc comment for parameter "$dataSource" missing
Loading history...
introduced by
Doc comment for parameter "$parameters" missing
Loading history...
18
     * @param $dataSource
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
19
     * @param $alias
0 ignored issues
show
introduced by
Missing parameter name
Loading history...
20
     */
21
    public function addDataSource($dataSource, $parameters)
22
    {
23
        $method = $parameters['method'];
24
        $data = function () use ($dataSource, $method) {
25
            return $dataSource->{$method}();
26
        };
27
        $this->dataSource[$parameters['alias']] = [
28
            'data'       => $data,
29
            'dataSource' => $dataSource,
30
            'parameters' => $parameters,
31
        ];
32
    }
33
34
    /**
35
     * @param string $alias
36
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
37
    public function getData($alias)
38
    {
39
        return $this->dataSource[$alias]['data'];
40
    }
41
42
    /**
43
     * @param string $alias
44
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
45
    public function getDataSource($alias)
46
    {
47
        return $this->dataSource[$alias]['dataSource'];
48
    }
49
50
    /**
51
     * @param string $alias
52
     */
0 ignored issues
show
introduced by
Missing @return tag in function comment
Loading history...
53
    public function getDataSourceParameters($alias)
54
    {
55
        return $this->dataSource[$alias]['parameters'];
56
    }
57
58
    /**
59
     * @return array
60
     */
61
    public function getDataSources()
62
    {
63
        return $this->dataSource;
64
    }
65
}
66