RowMapper::setParameters()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 5
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: dam
5
 * Date: 03/12/15
6
 * Time: 10:38
7
 */
8
9
namespace Mouf\Utils\DataSource\Mappers;
10
11
12
use Mouf\Utils\DataSource\Interfaces\PickerInterface;
13
use Mouf\Utils\DataSource\Interfaces\RowInterface;
14
15
class RowMapper implements RowInterface
16
{
17
    /**
18
     * @var array<string,PickerInterface>
19
     */
20
    private $matchers;
21
22
    /**
23
     * @var RowInterface
24
     */
25
    private $row;
26
27
    /**
28
     * @var array
29
     */
30
    private $params;
31
32
    /**
33
     * @Important
34
     * @param array<string,PickerInterface> $matchers
35
     * @param RowInterface $rowSource
36
     * @param array $params
37
     */
38
    public function __construct(array $matchers, RowInterface $rowSource, array $params = array())
39
    {
40
        $this->matchers = $matchers;
41
        $this->row = $rowSource;
42
        $this->params = $params;
43
    }
44
45
    /**
46
     * @return array
47
     */
48
    public function getRow()
49
    {
50
        return array_map(function(PickerInterface $picker) {
51
            return $picker->pick($this->row);
52
        }, $this->matchers);
53
    }
54
55
    /**
56
     * @param array $params
57
     */
58
    public function setParameters(array $params)
59
    {
60
        $this->params = $params;
61
        $this->row->setParameters($this->params);
62
    }
63
}