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