feat(demo): add story 1 — Sorano: Rock and Time

This commit is contained in:
2026-06-20 21:19:57 +02:00
parent 42ed59a6b3
commit 8f87155c1d
5508 changed files with 1595740 additions and 124 deletions
@@ -0,0 +1,34 @@
<?php
namespace SourceSpan;
/**
* A mixin for easily implementing {@see SourceLocation}.
*
* @internal
*/
abstract class SourceLocationMixin implements SourceLocation
{
public function distance(SourceLocation $other): int
{
if (!Util::isSameUrl($this->getSourceUrl(), $other->getSourceUrl())) {
throw new \InvalidArgumentException("Source URLs \"{$this->getSourceUrl()}\" and \"{$other->getSourceUrl()}\" don't match.");
}
return abs($this->getOffset() - $other->getOffset());
}
public function pointSpan(): SourceSpan
{
return new SimpleSourceSpan($this, $this, '');
}
public function compareTo(SourceLocation $other): int
{
if (!Util::isSameUrl($this->getSourceUrl(), $other->getSourceUrl())) {
throw new \InvalidArgumentException("Source URLs \"{$this->getSourceUrl()}\" and \"{$other->getSourceUrl()}\" don't match.");
}
return $this->getOffset() - $other->getOffset();
}
}