Initial commit

This commit is contained in:
2025-10-05 13:55:28 +02:00
commit 68d521677a
767 changed files with 46947 additions and 0 deletions
@@ -0,0 +1,42 @@
<?php
declare(strict_types=1);
namespace App\Aggregator\Domain\Model\ValueObject;
use App\SharedKernel\Domain\Assert;
/**
* Class Link.
*
* @author bernard-ng <bernard@devscast.tech>
*/
final readonly class Link implements \Stringable, \JsonSerializable
{
public string $link;
private function __construct(string $url, ?string $source = null)
{
if (! str_starts_with($url, 'http')) {
Assert::notNull($source, 'You must provide a source if the URL is not absolute.');
$this->link = sprintf('https://%s/%s', $source, trim($url, '/'));
} else {
$this->link = $url;
}
}
public function __toString(): string
{
return $this->link;
}
public static function from(string $url, ?string $source = null): self
{
return new self($url, $source);
}
public function jsonSerialize(): string
{
return $this->link;
}
}