$attributes * @return \IPLib\Address\AddressInterface|null * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed */ public function get(Model $model, string $key, mixed $value, array $attributes) { // phpcs:enable return \IPLib\Factory::parseAddressString($value); } /** * Transform the attribute to its underlying model values. * * @param \Illuminate\Database\Eloquent\Model $model * @param string $key * @param \IPLib\Address\AddressInterface|string|null $value * @param array $attributes * @return mixed * @throws \RuntimeException If value is not or instance of \IPLib\Address\AddressInterface. * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed * @phpcs:disable Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed */ public function set(Model $model, string $key, mixed $value, array $attributes) { // phpcs:enable if (is_null($value)) { return null; } if (is_string($value)) { $value = \IPLib\Factory::parseAddressString($value); } if (!is_object($value) or !($value instanceof \IPLib\Address\AddressInterface)) { throw new \RuntimeException( "{$key} has to be instance of " . \IPLib\Address\AddressInterface::class ); } $value->getAddressType(); return $value; } }