forked from openspout/openspout
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComment.php
More file actions
137 lines (125 loc) · 3.41 KB
/
Comment.php
File metadata and controls
137 lines (125 loc) · 3.41 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
declare(strict_types=1);
namespace OpenSpout\Common\Entity\Comment;
use InvalidArgumentException;
/**
* This class defines a comment that can be added to a cell.
*/
final readonly class Comment
{
public const string DEFAULT_HEIGHT = '55.5pt';
public const string DEFAULT_WIDTH = '96pt';
public const string DEFAULT_MARGIN_LEFT = '59.25pt';
public const string DEFAULT_MARGIN_TOP = '1.5pt';
public const string DEFAULT_FILL_COLOR = '#FFFFE1';
/**
* @param list<TextRun> $textRuns
*/
public function __construct(
public string $height = self::DEFAULT_HEIGHT,
public string $width = self::DEFAULT_WIDTH,
public string $marginLeft = self::DEFAULT_MARGIN_LEFT,
public string $marginTop = self::DEFAULT_MARGIN_TOP,
public bool $visible = false,
public string $fillColor = self::DEFAULT_FILL_COLOR,
public array $textRuns = [],
) {
foreach ($this->textRuns as $index => $textRun) {
if (!$textRun instanceof TextRun) {
throw new InvalidArgumentException(\sprintf(
'TextRuns must be instance of %s, %s provided at index %s',
TextRun::class,
get_debug_type($textRun),
$index
));
}
}
}
public function withHeight(string $height): self
{
return new self(
$height,
$this->width,
$this->marginLeft,
$this->marginTop,
$this->visible,
$this->fillColor,
$this->textRuns
);
}
public function withWidth(string $width): self
{
return new self(
$this->height,
$width,
$this->marginLeft,
$this->marginTop,
$this->visible,
$this->fillColor,
$this->textRuns
);
}
public function withMarginLeft(string $marginLeft): self
{
return new self(
$this->height,
$this->width,
$marginLeft,
$this->marginTop,
$this->visible,
$this->fillColor,
$this->textRuns
);
}
public function withMarginTop(string $marginTop): self
{
return new self(
$this->height,
$this->width,
$this->marginLeft,
$marginTop,
$this->visible,
$this->fillColor,
$this->textRuns
);
}
public function withVisible(bool $visible): self
{
return new self(
$this->height,
$this->width,
$this->marginLeft,
$this->marginTop,
$visible,
$this->fillColor,
$this->textRuns
);
}
public function withFillColor(string $fillColor): self
{
return new self(
$this->height,
$this->width,
$this->marginLeft,
$this->marginTop,
$this->visible,
$fillColor,
$this->textRuns
);
}
/**
* @param list<TextRun> $textRuns
*/
public function withTextRuns(array $textRuns): self
{
return new self(
$this->height,
$this->width,
$this->marginLeft,
$this->marginTop,
$this->visible,
$this->fillColor,
$textRuns
);
}
}