Test Failed
Push — develop ( 90366f...812a46 )
by Adrien
28:16
created

Dimension::getVisible()   A

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 PhpOffice\PhpSpreadsheet\Worksheet;
4
5
use PhpOffice\PhpSpreadsheet\Exception as PhpSpreadsheetException;
6
7
abstract class Dimension
8
{
9
    /**
10
     * Visible?
11
     *
12
     * @var bool
13
     */
14
    private $visible = true;
15
16
    /**
17
     * Outline level.
18
     *
19
     * @var int
20
     */
21
    private $outlineLevel = 0;
22
23
    /**
24
     * Collapsed.
25
     *
26
     * @var bool
27
     */
28
    private $collapsed = false;
29
30
    /**
31
     * Index to cellXf. Null value means row has no explicit cellXf format.
32
     *
33
     * @var null|int
34
     */
35
    private $xfIndex;
36
37
    /**
38
     * Create a new Dimension.
39
     *
40
     * @param int $initialValue Numeric row index
41
     */
42 153
    public function __construct($initialValue = null)
43
    {
44
        // set dimension as unformatted by default
45 153
        $this->xfIndex = $initialValue;
46 153
    }
47
48
    /**
49
     * Get Visible.
50
     *
51
     * @return bool
52
     */
53 63
    public function getVisible()
54
    {
55 63
        return $this->visible;
56
    }
57
58
    /**
59
     * Set Visible.
60
     *
61
     * @param bool $pValue
62
     *
63
     * @return Dimension
64
     */
65 24
    public function setVisible($pValue)
66
    {
67 24
        $this->visible = $pValue;
68
69 24
        return $this;
70
    }
71
72
    /**
73
     * Get Outline Level.
74
     *
75
     * @return int
76
     */
77 58
    public function getOutlineLevel()
78
    {
79 58
        return $this->outlineLevel;
80
    }
81
82
    /**
83
     * Set Outline Level.
84
     * Value must be between 0 and 7.
85
     *
86
     * @param int $pValue
87
     *
88
     * @throws PhpSpreadsheetException
89
     *
90
     * @return Dimension
91
     */
92 18
    public function setOutlineLevel($pValue)
93
    {
94 18
        if ($pValue < 0 || $pValue > 7) {
95
            throw new PhpSpreadsheetException('Outline level must range between 0 and 7.');
96
        }
97
98 18
        $this->outlineLevel = $pValue;
99
100 18
        return $this;
101
    }
102
103
    /**
104
     * Get Collapsed.
105
     *
106
     * @return bool
107
     */
108 56
    public function getCollapsed()
109
    {
110 56
        return $this->collapsed;
111
    }
112
113
    /**
114
     * Set Collapsed.
115
     *
116
     * @param bool $pValue
117
     *
118
     * @return Dimension
119
     */
120 18
    public function setCollapsed($pValue)
121
    {
122 18
        $this->collapsed = $pValue;
123
124 18
        return $this;
125
    }
126
127
    /**
128
     * Get index to cellXf.
129
     *
130
     * @return int
131
     */
132 78
    public function getXfIndex()
133
    {
134 78
        return $this->xfIndex;
135
    }
136
137
    /**
138
     * Set index to cellXf.
139
     *
140
     * @param int $pValue
141
     *
142
     * @return Dimension
143
     */
144 36
    public function setXfIndex($pValue)
145
    {
146 36
        $this->xfIndex = $pValue;
147
148 36
        return $this;
149
    }
150
151
    /**
152
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
153
     */
154 View Code Duplication
    public function __clone()
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
155
    {
156
        $vars = get_object_vars($this);
157
        foreach ($vars as $key => $value) {
158
            if (is_object($value)) {
159
                $this->$key = clone $value;
160
            } else {
161
                $this->$key = $value;
162
            }
163
        }
164
    }
165
}
166