Link::decorate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Boduch\Grid\Decorators;
4
5
use Boduch\Grid\Cell;
6
7
class Link extends Decorator
8
{
9
    /**
10
     * @var \Closure
11
     */
12
    protected $closure;
13
14
    /**
15
     * @param \Closure $closure
16
     * @return $this
17
     */
18
    public function render(\Closure $closure)
19
    {
20
        $this->closure = $closure;
21
22
        return $this;
23
    }
24
25
    /**
26
     * @param Cell $cell
27
     * @return void
28
     */
29
    public function decorate(Cell $cell)
30
    {
31
        // disable auto escape so we can display <a> html tag in cell
32
        $cell->getColumn()->setAutoescape(false);
33
34
        $cell->setValue($this->closure->call($cell, $cell->getData()));
35
    }
36
}
37