Header::getAttributeName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace hamburgscleanest\DataTables\Models;
4
5
use hamburgscleanest\DataTables\Interfaces\HeaderFormatter;
6
7
/**
8
 * Class Header
9
 * @package hamburgscleanest\hamburgscleanest\DataTables\Models
10
 */
11
class Header {
12
13
    /** @var string */
14
    public $key;
15
16
    /** @var string */
17
    private $_attributeName;
18
19
    /**
20
     * Header constructor.
21
     * @param string $columnKey
22
     */
23 45
    public function __construct(string $columnKey)
24
    {
25 45
        $this->_attributeName = $this->key = $columnKey;
26 45
    }
27
28
    /**
29
     * Get the original attribute name.
30
     *
31
     * @return string
32
     */
33 13
    public function getAttributeName() : string
34
    {
35 13
        return $this->_attributeName;
36
    }
37
38
    /**
39
     * @param array $headerFormatters
40
     * @return Header
41
     */
42 44
    public function formatArray(array $headerFormatters) : Header
43
    {
44 44
        foreach ($headerFormatters as $formatter)
45
        {
46 12
            $this->format($formatter);
47
        }
48
49 44
        return $this;
50
    }
51
52
    /**
53
     * @param HeaderFormatter $headerFormatter
54
     * @return Header
55
     */
56 12
    public function format(HeaderFormatter $headerFormatter) : Header
57
    {
58 12
        $headerFormatter->format($this);
59
60 12
        return $this;
61
    }
62
63
    /**
64
     * @return string
65
     */
66
    public function print() : string
67
    {
68
        return '<th>' . $this->key . '</th>';
69
    }
70
}