| 1 |
<?php |
| 2 |
|
| 3 |
namespace TablePress\PhpOffice\PhpSpreadsheet\Worksheet; |
| 4 |
|
| 5 |
use TablePress\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 |
public function __construct(string $sqref, string $password = '', string $name = '', string $securityDescriptor = '') |
| 21 |
{ |
| 22 |
$this->sqref = $sqref; |
| 23 |
$this->name = $name; |
| 24 |
$this->password = $password; |
| 25 |
$this->securityDescriptor = $securityDescriptor; |
| 26 |
} |
| 27 |
|
| 28 |
public function getSqref(): string |
| 29 |
{ |
| 30 |
return $this->sqref; |
| 31 |
} |
| 32 |
|
| 33 |
public function getName(): string |
| 34 |
{ |
| 35 |
return $this->name ?: ('p' . md5($this->sqref)); |
| 36 |
} |
| 37 |
|
| 38 |
public function getPassword(): string |
| 39 |
{ |
| 40 |
return $this->password; |
| 41 |
} |
| 42 |
|
| 43 |
public function getSecurityDescriptor(): string |
| 44 |
{ |
| 45 |
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 |
public function allRanges(): array |
| 56 |
{ |
| 57 |
return Coordinate::allRanges($this->sqref, false); |
| 58 |
} |
| 59 |
} |
| 60 |
|