2024-07-21 01:47:21 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* @author Daniel J. Summers <daniel@bitbadger.solutions>
|
|
|
|
* @license MIT
|
|
|
|
*/
|
|
|
|
|
|
|
|
declare(strict_types=1);
|
2024-06-29 15:46:16 +00:00
|
|
|
|
|
|
|
namespace Test;
|
|
|
|
|
|
|
|
use Square\Pjson\JsonDataSerializable;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A serializable ID wrapper class
|
|
|
|
*/
|
2024-09-27 02:15:00 +00:00
|
|
|
final class PjsonId implements JsonDataSerializable
|
2024-06-29 15:46:16 +00:00
|
|
|
{
|
|
|
|
public function __construct(protected string $value) { }
|
|
|
|
|
|
|
|
public function toJsonData(): string
|
|
|
|
{
|
|
|
|
return $this->value;
|
|
|
|
}
|
|
|
|
|
2024-09-27 02:15:00 +00:00
|
|
|
/**
|
|
|
|
* @param mixed $jd JSON data
|
|
|
|
* @param mixed[]|string $path path segments
|
|
|
|
* @return static
|
|
|
|
*/
|
2024-06-29 15:46:16 +00:00
|
|
|
public static function fromJsonData($jd, array|string $path = []): static
|
|
|
|
{
|
|
|
|
return new static($jd);
|
|
|
|
}
|
|
|
|
}
|