Completed
Push — develop ( 4fd8e7...d3e769 )
by Adrien
14:12 queued 07:04
created

Supervisor::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 0
cts 3
cp 0
crap 2
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Style;
4
5
abstract class Supervisor
6
{
7
    /**
8
     * Supervisor?
9
     *
10
     * @var bool
11
     */
12
    protected $isSupervisor;
13
14
    /**
15
     * Parent. Only used for supervisor.
16
     *
17
     * @var \PhpOffice\PhpSpreadsheet\Style
18
     */
19
    protected $parent;
20
21
    /**
22
     * Create a new Supervisor.
23
     *
24
     * @param bool $isSupervisor Flag indicating if this is a supervisor or not
25
     *                                    Leave this value at default unless you understand exactly what
26
     *                                        its ramifications are
27
     */
28
    public function __construct($isSupervisor = false)
29
    {
30
        // Supervisor?
31
        $this->isSupervisor = $isSupervisor;
32
    }
33
34
    /**
35
     * Bind parent. Only used for supervisor.
36
     *
37
     * @param Style $parent
38
     * @param null|mixed $parentPropertyName
39
     *
40
     * @return Supervisor
41
     */
42
    public function bindParent($parent, $parentPropertyName = null)
43
    {
44
        $this->parent = $parent;
0 ignored issues
show
Documentation Bug introduced by
It seems like $parent of type object<PhpOffice\PhpSpreadsheet\Style\Style> is incompatible with the declared type object<PhpOffice\PhpSpreadsheet\Style> of property $parent.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
46
        return $this;
47
    }
48
49
    /**
50
     * Is this a supervisor or a cell style component?
51
     *
52
     * @return bool
53
     */
54
    public function getIsSupervisor()
55
    {
56
        return $this->isSupervisor;
57
    }
58
59
    /**
60
     * Get the currently active sheet. Only used for supervisor.
61
     *
62
     * @return \PhpOffice\PhpSpreadsheet\Worksheet
63
     */
64
    public function getActiveSheet()
65
    {
66
        return $this->parent->getActiveSheet();
67
    }
68
69
    /**
70
     * Get the currently active cell coordinate in currently active sheet.
71
     * Only used for supervisor.
72
     *
73
     * @return string E.g. 'A1'
74
     */
75
    public function getSelectedCells()
76
    {
77
        return $this->getActiveSheet()->getSelectedCells();
78
    }
79
80
    /**
81
     * Get the currently active cell coordinate in currently active sheet.
82
     * Only used for supervisor.
83
     *
84
     * @return string E.g. 'A1'
85
     */
86
    public function getActiveCell()
87
    {
88
        return $this->getActiveSheet()->getActiveCell();
89
    }
90
91
    /**
92
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
93
     */
94
    public function __clone()
95
    {
96
        $vars = get_object_vars($this);
97
        foreach ($vars as $key => $value) {
98
            if ((is_object($value)) && ($key != 'parent')) {
99
                $this->$key = clone $value;
100
            } else {
101
                $this->$key = $value;
102
            }
103
        }
104
    }
105
}
106