Completed
Push — master ( 9d2442...b1f272 )
by Denis
01:49
created

BaseColumn::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
1
<?php
2
3
namespace Woo\GridView\Columns;
4
5
use Woo\GridView\GridViewHelper;
6
7
abstract class BaseColumn
8
{
9
    public $title = '';
10
11
    public $value = '';
12
13
    public $headerHtmlOptions = [];
14
15
    public $contentHtmlOptions = [];
16
17
    public function __construct(array $config)
18
    {
19
        GridViewHelper::loadConfig($this, $config);
20
21
        GridViewHelper::testConfig($this, [
22
            'title' => 'string',
23
            'value' => 'any',
24
            'headerHtmlOptions' => 'array',
25
            'contentHtmlOptions' => 'array',
26
        ]);
27
    }
28
29
    /**
30
     * Formatted header html options
31
     * @return string
32
     */
33
    public function headerHtmlOptions() : string
34
    {
35
        return GridViewHelper::htmlOptionsToString($this->headerHtmlOptions);
36
    }
37
38
    /**
39
     * Formatted content html options
40
     * @return string
41
     */
42
    public function contentHtmlOptions() : string
43
    {
44
        return GridViewHelper::htmlOptionsToString($this->contentHtmlOptions);
45
    }
46
47
    /**
48
     * Render column value for row
49
     * @param array|object $row
50
     * @return string|mixed
51
     */
52
    public abstract function renderValue($row);
53
}