chore: complete update
This commit is contained in:
27
src/Framework/Http/IpAddress.php
Normal file
27
src/Framework/Http/IpAddress.php
Normal file
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace App\Framework\Http;
|
||||
|
||||
/**
|
||||
* Value Object für IP-Adressen
|
||||
*/
|
||||
final readonly class IpAddress
|
||||
{
|
||||
public function __construct(
|
||||
public string $value
|
||||
) {
|
||||
if (!filter_var($value, FILTER_VALIDATE_IP)) {
|
||||
throw new \InvalidArgumentException("Invalid IP address: {$value}");
|
||||
}
|
||||
}
|
||||
|
||||
public function isPrivate(): bool
|
||||
{
|
||||
return !filter_var($this->value, FILTER_VALIDATE_IP, FILTER_FLAG_NO_PRIV_RANGE);
|
||||
}
|
||||
|
||||
public function __toString(): string
|
||||
{
|
||||
return $this->value;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user