for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Koriym\AppStateDiagram;
use Koriym\AppStateDiagram\Exception\InvalidLinkRelationException;
use stdClass;
use function json_encode;
use function sprintf;
final class LinkRelation
{
/** @var string */
public $href;
public $rel;
public $title;
public function __construct(stdClass $link)
if (! isset($link->href)) {
throw new InvalidLinkRelationException((string) json_encode($link));
}
if (! isset($link->rel)) {
/** @psalm-suppress MixedAssignment */
$this->href = $link->href;
$this->rel = $link->rel;
$this->title = $link->title ?? '';
public function __toString(): string
return sprintf(' * %s', $this->toLink());
private function toLink(): string
$str = sprintf('rel: %s <a rel="%s" href="%s">%s</a>', $this->rel, $this->rel, $this->href, $this->href);
if ($this->title !== '') {
$str .= " {$this->title}";
return $str;