Skip to content

Commit

Permalink
Add transactional content method
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Apr 3, 2024
1 parent 7b05772 commit 3f15d84
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Tag/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ public function shift(int $offset, bool $ltrim = true): void
$this->offset += $size - \strlen($this->value);
}

/**
* @param callable(self):bool $context
*/
public function transactional(callable $context): void
{
$offset = $this->offset;
$value = $this->value;

if ($context($this) === false) {
$this->offset = $offset;
$this->value = $value;
}
}

public function getTagException(string $message, \Throwable $previous = null): InvalidTagException
{
return new InvalidTagException(
Expand Down

0 comments on commit 3f15d84

Please sign in to comment.