Completed
Push — master ( 03a7df...02e633 )
by Adam
02:32
created

Action   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 59
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
c 3
b 0
f 0
dl 0
loc 59
rs 10
wmc 5
lcom 1
cbo 1

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getColumn() 0 4 1
A setValue() 0 4 1
A getValue() 0 10 2
1
<?php
2
3
namespace Boduch\Grid;
4
5
class Action implements CellInterface
6
{
7
    /**
8
     * @var RowActions\RowAction[]
9
     */
10
    protected $rowActions;
11
12
    /**
13
     * @var mixed
14
     */
15
    protected $data;
16
17
    /**
18
     * @var Column
19
     */
20
    protected $column;
21
22
    /**
23
     * @param Column $column
24
     * @param RowActions\RowAction[] $rowActions
25
     * @param mixed $data
26
     */
27
    public function __construct(Column $column, $rowActions, $data)
28
    {
29
        $this->column = $column;
30
        $this->rowActions = $rowActions;
31
        $this->data = $data;
32
    }
33
34
    /**
35
     * @return Column
36
     */
37
    public function getColumn()
38
    {
39
        return $this->column;
40
    }
41
42
    /**
43
     * @param mixed $value
44
     */
45
    public function setValue($value)
46
    {
47
        throw new \InvalidArgumentException('Can\'t set action value.');
48
    }
49
50
    /**
51
     * @return string
52
     */
53
    public function getValue()
54
    {
55
        $html = '';
56
57
        foreach ($this->rowActions as $rowAction) {
58
            $html = $rowAction->render($this->data);
59
        }
60
61
        return $html;
62
    }
63
}
64