Completed
Push — master ( e66c58...0a0a0f )
by Daniel
9s
created

SelectColumn   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 30
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A buildCell() 0 9 1
A configureOptions() 0 4 1
A getParent() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Psi\Component\Grid\Column;
6
7
use Psi\Component\Grid\ColumnInterface;
8
use Psi\Component\Grid\View\Cell;
9
use Psi\Component\ObjectAgent\AgentFinder;
10
use Symfony\Component\OptionsResolver\OptionsResolver;
11
12
class SelectColumn implements ColumnInterface
13
{
14
    const INPUT_NAME = '_select';
15
16
    private $agentFinder;
17
18
    public function __construct(AgentFinder $agentFinder)
19
    {
20
        $this->agentFinder = $agentFinder;
21
    }
22
23
    public function buildCell(Cell $cell, array $options)
24
    {
25
        $cell->template = 'Select';
26
27
        // TODO: maybe use the property accessor here instead? and default to the property "id".
28
        $agent = $this->agentFinder->findFor(get_class($cell->context));
29
30
        $cell->value = $agent->getIdentifier($cell->context);
31
    }
32
33
    public function configureOptions(OptionsResolver $options)
34
    {
35
        $options->setDefault('property', null);
36
    }
37
38
    public function getParent()
39
    {
40
    }
41
}
42