CStatic::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 3
c 0
b 0
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
cc 1
nc 1
nop 3
crap 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 CStatic
11
 * @package kalanis\kw_table\core\Table\Columns
12
 * Static value defined on init
13
 */
14
class CStatic extends AColumn
15
{
16
    private string $value = '';
17
    private string $class = '';
18
19 2
    public function __construct(string $value, string $class = '', string $sourceName = '')
20
    {
21 2
        $this->value = $value;
22 2
        $this->class = $class;
23 2
        $this->sourceName = $sourceName;
24 2
    }
25
26 2
    public function getValue(IRow $source)
27
    {
28 2
        return !empty($this->class) ? $this->returnWithClass() : $this->value;
29
    }
30
31 1
    private function returnWithClass(): string
32
    {
33 1
        return '<span class="' . $this->class . '">' . $this->value . '</span>';
34
    }
35
}
36