*/ class OrderReferenceCast implements CastsAttributes { /** @param array $attributes */ public function get($model, string $key, $value, array $attributes): OrderReference { if ($value === null || ! is_string($value)) { throw new \UnexpectedValueException('OrderReference cannot be null.'); } return OrderReference::fromString($value); } /** @param array $attributes */ public function set($model, string $key, $value, array $attributes): string { if (! $value instanceof OrderReference) { throw new \UnexpectedValueException('The given value is not an instance of OrderReference.'); } return (string) $value; } }