Passed
Push — master ( efa0c0...317477 )
by
unknown
19:26 queued 11:40
created

ProtectedRange::allRanges()   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
eloc 1
c 0
b 0
f 0
dl 0
loc 3
rs 10
ccs 2
cts 2
cp 1
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace PhpOffice\PhpSpreadsheet\Worksheet;
4
5
use PhpOffice\PhpSpreadsheet\Cell\Coordinate;
6
7
class ProtectedRange
8
{
9
    private string $name = '';
10
11
    private string $password = '';
12
13
    private string $sqref;
14
15
    private string $securityDescriptor = '';
16
17
    /**
18
     * No setters aside from constructor.
19
     */
20 26
    public function __construct(string $sqref, string $password = '', string $name = '', string $securityDescriptor = '')
21
    {
22 26
        $this->sqref = $sqref;
23 26
        $this->name = $name;
24 26
        $this->password = $password;
25 26
        $this->securityDescriptor = $securityDescriptor;
26
    }
27
28
    public function getSqref(): string
29
    {
30
        return $this->sqref;
31
    }
32
33 9
    public function getName(): string
34
    {
35 9
        return $this->name ?: ('p' . md5($this->sqref));
36
    }
37
38 20
    public function getPassword(): string
39
    {
40 20
        return $this->password;
41
    }
42
43 9
    public function getSecurityDescriptor(): string
44
    {
45 9
        return $this->securityDescriptor;
46
    }
47
48
    /**
49
     * Split range into coordinate strings.
50
     *
51
     * @return array<array<string>> Array containing one or more arrays containing one or two coordinate strings
52
     *                                e.g. ['B4','D9'] or [['B4','D9'], ['H2','O11']]
53
     *                                        or ['B4']
54
     */
55 1
    public function allRanges(): array
56
    {
57 1
        return Coordinate::allRanges($this->sqref, false);
58
    }
59
}
60