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