Object   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 71
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Importance

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

6 Methods

Rating   Name   Duplication   Size   Complexity  
A setObject() 0 4 1
A getObject() 0 4 1
A addObjectParameterColumn() 0 7 1
A getObjectParametersColumn() 0 4 1
A setObjectParameter() 0 4 1
A toString() 0 4 1
1
<?php
2
3
namespace ZfcDatagrid\Column\DataPopulation;
4
5
use ZfcDatagrid\Column;
6
7
/**
8
 * Get the data from an external object.
9
 */
10
class Object implements DataPopulationInterface
11
{
12
    /**
13
     * @var ObjectAwareInterface
14
     */
15
    private $object;
16
17
    /**
18
     * @var array
19
     */
20
    private $objectParameters = [];
21
22
    /**
23
     * @param ObjectAwareInterface $object
24
     *
25
     * @throws \Exception
26
     */
27
    public function setObject(ObjectAwareInterface $object)
28
    {
29
        $this->object = $object;
30
    }
31
32
    /**
33
     * @return ObjectAwareInterface
34
     */
35
    public function getObject()
36
    {
37
        return $this->object;
38
    }
39
40
    /**
41
     * Apply a dynamic parameter based on row/column value.
42
     *
43
     * @param string                $objectParameterName
44
     * @param Column\AbstractColumn $column
45
     */
46
    public function addObjectParameterColumn($objectParameterName, Column\AbstractColumn $column)
47
    {
48
        $this->objectParameters[] = [
49
            'objectParameterName' => $objectParameterName,
50
            'column' => $column,
51
        ];
52
    }
53
54
    /**
55
     * @return array
56
     */
57
    public function getObjectParametersColumn()
58
    {
59
        return $this->objectParameters;
60
    }
61
62
    /**
63
     * Directly apply a "static" parameter.
64
     *
65
     * @param string $name
66
     * @param mixed  $value
67
     */
68
    public function setObjectParameter($name, $value)
69
    {
70
        $this->getObject()->setParameterFromColumn($name, $value);
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function toString()
77
    {
78
        return $this->getObject()->toString();
79
    }
80
}
81