-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathNumberFormatToken.php
69 lines (55 loc) · 1.57 KB
/
NumberFormatToken.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
namespace Aspera\Spreadsheet\XLSX;
/** Data of a single, syntactical token of a cell format. */
class NumberFormatToken
{
/** @var string Format code of this token. */
private $code;
/** @var bool Is this token in quotes or escaped via a backslash, Y/N. If true, $code should be output as-is. */
private $is_quoted = false;
/** @var ?int Index of the current square bracket section, starting at 0. null if this token is not in square brackets. */
private $square_bracket_index;
public function __construct(string $code)
{
$this->code = $code;
}
public function setCode(string $code): self
{
$this->code = $code;
return $this;
}
public function appendCode(string $code): void
{
$this->code .= $code;
}
public function getCode(): string
{
return $this->code;
}
public function setIsQuoted(bool $is_quoted): self
{
$this->is_quoted = $is_quoted;
return $this;
}
public function isQuoted(): bool
{
return $this->is_quoted;
}
public function setSquareBracketIndex(?int $square_bracket_index): self
{
$this->square_bracket_index = $square_bracket_index;
return $this;
}
public function getSquareBracketIndex(): ?int
{
return $this->square_bracket_index;
}
public function isInSquareBrackets(): bool
{
return $this->square_bracket_index !== null;
}
public function isScientificNotationE(): bool
{
return preg_match('{^[Ee][+-]$}', $this->code);
}
}