Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/BooleanCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,29 @@ public function getValue(): bool
{
return $this->value;
}

public function withValue(bool $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/DateIntervalCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,29 @@ public function getValue(): DateInterval
{
return $this->value;
}

public function withValue(DateInterval $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/DateTimeCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,29 @@ public function getValue(): DateTimeInterface
{
return $this->value;
}

public function withValue(DateTimeInterface $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/EmptyCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,29 @@ public function getValue(): ?string
{
return $this->value;
}

public function withValue(?string $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/ErrorCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,29 @@ public function getRawValue(): string
{
return $this->value;
}

public function withRawValue(string $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
30 changes: 30 additions & 0 deletions src/Common/Entity/Cell/FormulaCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,34 @@ public function getComputedValue(): bool|DateInterval|DateTimeImmutable|float|in
{
return $this->computedValue;
}

public function withValue(string $value): self
{
return new self($value, $this->computedValue, $this->style, $this->comment);
}

public function withComputedValue(bool|DateInterval|DateTimeImmutable|float|int|string|null $computedValue): self
{
return new self($this->value, $computedValue, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $this->computedValue, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, $this->computedValue, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->computedValue, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->computedValue, $this->style, null);
}
}
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/NumericCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,29 @@ public function getValue(): float|int
{
return $this->value;
}

public function withValue(float|int $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
25 changes: 25 additions & 0 deletions src/Common/Entity/Cell/StringCell.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,29 @@ public function getValue(): string
{
return $this->value;
}

public function withValue(string $value): self
{
return new self($value, $this->style, $this->comment);
}

public function withStyle(Style $style): self
{
return new self($this->value, $style, $this->comment);
}

public function withoutStyle(): self
{
return new self($this->value, null, $this->comment);
}

public function withComment(Comment $comment): self
{
return new self($this->value, $this->style, $comment);
}

public function withoutComment(): self
{
return new self($this->value, $this->style, null);
}
}
110 changes: 105 additions & 5 deletions src/Common/Entity/Comment/Comment.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,22 @@
*/
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 = '55.5pt',
public string $width = '96pt',
public string $marginLeft = '59.25pt',
public string $marginTop = '1.5pt',
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 = '#FFFFE1',
public string $fillColor = self::DEFAULT_FILL_COLOR,
public array $textRuns = [],
) {
foreach ($this->textRuns as $index => $textRun) {
Expand All @@ -34,4 +40,98 @@ public function __construct(
}
}
}

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
);
}
}
Loading
Loading