Completed
Pull Request — master (#127)
by De Cramer
04:50
created

AbstractColumn   A

Complexity

Total Complexity 15

Size/Duplication

Total Lines 140
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 62.5%

Importance

Changes 0
Metric Value
wmc 15
lcom 1
cbo 0
dl 0
loc 140
ccs 25
cts 40
cp 0.625
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getKey() 0 4 1
A setKey() 0 4 1
A getName() 0 4 1
A setName() 0 4 1
A getWidthCoeficiency() 0 4 1
A setWidthCoeficiency() 0 4 1
A getSortable() 0 4 1
A setSortable() 0 4 1
A getSortDirection() 0 4 1
A setSortDirection() 0 4 1
A getSortColumn() 0 4 1
A setSortColumn() 0 4 1
A toggleSortDirection() 0 8 2
1
<?php
2
3
namespace eXpansion\Framework\Core\Model\Gui\Grid\Column;
4
5
6
/**
7
 * Class AbstractColumn
8
 *
9
 * @package eXpansion\Framework\Core\Model\Gui\Grid\Column;
10
 * @author  oliver de Cramer <[email protected]>
11
 */
12
abstract class AbstractColumn
13
{
14
    /** @var bool */
15
    protected $sortable = false;
16
17
    /** @var string */
18
    protected $key;
19
20
    /** @var string */
21
    protected $name;
22
23
    /** @var float */
24
    protected $widthCoeficiency;
25
26
    /** @var string */
27
    protected $sortDirection = "ASC";
28
    /**
29
     * @var bool
30
     */
31
    protected $sortColumn = false;
32
33
    /**
34
     * AbstractColumn constructor.
35
     *
36
     * @param string $key
37
     * @param string $name
38
     * @param float $widthCoeficiency
39
     */
40 7
    public function __construct($key, $name, $widthCoeficiency)
41
    {
42 7
        $this->key = $key;
43 7
        $this->name = $name;
44 7
        $this->widthCoeficiency = $widthCoeficiency;
45 7
    }
46
47
    /**
48
     * @return string
49
     */
50 6
    public function getKey()
51
    {
52 6
        return $this->key;
53
    }
54
55
    /**
56
     * @param string $key
57
     */
58 1
    public function setKey($key)
59
    {
60 1
        $this->key = $key;
61 1
    }
62
63
    /**
64
     * @return string
65
     */
66 6
    public function getName()
67
    {
68 6
        return $this->name;
69
    }
70
71
    /**
72
     * @param string $name
73
     */
74 1
    public function setName($name)
75
    {
76 1
        $this->name = $name;
77 1
    }
78
79
    /**
80
     * @return float
81
     */
82 6
    public function getWidthCoeficiency()
83
    {
84 6
        return $this->widthCoeficiency;
85
    }
86
87
    /**
88
     * @param float $widthCoeficiency
89
     */
90 1
    public function setWidthCoeficiency($widthCoeficiency)
91
    {
92 1
        $this->widthCoeficiency = $widthCoeficiency;
93 1
    }
94
95
    /**
96
     * @return bool
97
     */
98 6
    public function getSortable()
99
    {
100 6
        return $this->sortable;
101
    }
102
103
    /**
104
     * @param bool $sortable
105
     */
106 6
    public function setSortable($sortable)
107
    {
108 6
        $this->sortable = $sortable;
109 6
    }
110
111
    /**
112
     * @return string
113
     */
114
    public function getSortDirection(): string
115
    {
116
        return $this->sortDirection;
117
    }
118
119
    /**
120
     * @param string $sortDirection
121
     */
122
    public function setSortDirection(string $sortDirection)
123
    {
124
        $this->sortDirection = $sortDirection;
125
    }
126
127
    /**
128
     * @return bool
129
     */
130
    public function getSortColumn(): bool
131
    {
132
        return $this->sortColumn;
133
    }
134
135
    /**
136
     * @param bool $sortColumn
137
     */
138
    public function setSortColumn(bool $sortColumn)
139
    {
140
        $this->sortColumn = $sortColumn;
141
    }
142
143
    public function toggleSortDirection()
144
    {
145
        if ($this->sortDirection == "ASC") {
146
            $this->sortDirection = "DESC";
147
        } else {
148
            $this->sortDirection = "ASC";
149
        }
150
    }
151
}
152