Lines
100.00%
3 / 3
Methods
100.00%
2 / 2
Classes
100.00%
1 / 1
| Name | Lines | Methods | CRAP | ||||
|---|---|---|---|---|---|---|---|
| __construct | 100.00% | 1 / 1 | 100.00% | 1 / 1 | 1 | ||
| isBanned | 100.00% | 2 / 2 | 100.00% | 1 / 1 | 1 | ||
| 32 | readonly class Network | |
| 33 | { | |
| 34 | /** | |
| 35 | * Constructor. | |
| 36 | */ | |
| 37 | public function __construct( | |
| 38 | private Configuration $configuration, | |
| 39 | ) { | |
| 40 | } | |
| 41 | ||
| 42 | /** | |
| 43 | * Performs a check if an IPv4 or IPv6 address is banned. | |
| 44 | * | |
| 45 | * @param string $ipAddress IPv4 or IPv6 address | |
| 46 | * @return bool false, if not banned | |
| 47 | */ | |
| 48 | public function isBanned(string $ipAddress): bool | |
| 49 | { | |
| 50 | $bannedIps = explode(separator: ' ', string: (string) $this->configuration->get(item: 'security.bannedIPs')); | |
| 51 | return IpUtils::checkIp($ipAddress, $bannedIps); | |
| 52 | } | |
| 53 | } |