Completed
Push — develop ( d3e769...440bfe )
by Adrien
22:10
created

Supervisor::getActiveCell()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 0
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
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 124
    public function __construct($isSupervisor = false)
29
    {
30
        // Supervisor?
31 124
        $this->isSupervisor = $isSupervisor;
32 124
    }
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 124
    public function bindParent($parent, $parentPropertyName = null)
43
    {
44 124
        $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 124
        return $this;
47
    }
48
49
    /**
50
     * Is this a supervisor or a cell style component?
51
     *
52
     * @return bool
53
     */
54 18
    public function getIsSupervisor()
55
    {
56 18
        return $this->isSupervisor;
57
    }
58
59
    /**
60
     * Get the currently active sheet. Only used for supervisor.
61
     *
62
     * @return \PhpOffice\PhpSpreadsheet\Worksheet
63
     */
64 46
    public function getActiveSheet()
65
    {
66 46
        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 46
    public function getSelectedCells()
76
    {
77 46
        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 9
    public function getActiveCell()
87
    {
88 9
        return $this->getActiveSheet()->getActiveCell();
89
    }
90
91
    /**
92
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
93
     */
94 48 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...
95
    {
96 48
        $vars = get_object_vars($this);
97 48
        foreach ($vars as $key => $value) {
98 48
            if ((is_object($value)) && ($key != 'parent')) {
99 48
                $this->$key = clone $value;
100
            } else {
101 48
                $this->$key = $value;
102
            }
103
        }
104 48
    }
105
}
106