Func   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getValue() 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 Func
11
 * @package kalanis\kw_table\core\Table\Columns
12
 * Each row in Column will pass through external function
13
 */
14
class Func extends AColumn
15
{
16
    /** @var callable */
17
    protected $callback;
18
    /** @var array<int, float|int|string|bool|null> */
19
    protected array $param;
20
21
    /**
22
     * @param string $sourceName
23
     * @param callable $callback
24
     * @param array<int, float|int|string|bool|null> $param+
25
     */
26 1
    public function __construct(string $sourceName, $callback, array $param = [])
27
    {
28 1
        $this->sourceName = $sourceName;
29 1
        $this->callback = $callback;
30 1
        $this->param = $param;
31 1
    }
32
33 1
    public function getValue(IRow $source)
34
    {
35 1
        $param = array_merge([parent::getValue($source)], $this->param);
36 1
        return call_user_func_array($this->callback, $param);
37
    }
38
}
39