EscFunc   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 6
dl 0
loc 20
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getValue() 0 3 1
A __construct() 0 4 1
1
<?php
2
3
namespace kalanis\kw_table\core\Table\Columns;
4
5
6
use kalanis\kw_connect\core\Interfaces\IRow;
7
8
9
/**
10
 * Class EscFunc
11
 * @package kalanis\kw_table\core\Table\Columns
12
 * Each row in Column will pass through external function - this one is escaped
13
 */
14
class EscFunc extends AColumn
15
{
16
    use TEscapedValue;
17
18
    /** @var callable */
19
    protected $callback;
20
21
    /**
22
     * @param string $sourceName
23
     * @param callable $callback
24
     */
25 1
    public function __construct(string $sourceName, $callback)
26
    {
27 1
        $this->sourceName = $sourceName;
28 1
        $this->callback = $callback;
29 1
    }
30
31 1
    public function getValue(IRow $source)
32
    {
33 1
        return $this->valueEscape(call_user_func($this->callback, parent::getValue($source)));
34
    }
35
}