Header   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 12
c 1
b 0
f 0
dl 0
loc 58
ccs 12
cts 12
cp 1
rs 10
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A print() 0 3 1
A getAttributeName() 0 3 1
A format() 0 5 1
A formatArray() 0 8 2
A __construct() 0 3 1
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
}