getRemoteAddress(); $this->ip = $remoteAddress === '' ? null : new Address($remoteAddress); } public static function isValid(string $ip): bool { return Address::isValid($ip); } public function matches(IRange... $ranges): bool { return $this->ip === null ? true : $this->ip->matches(... $ranges); } public function allowsAdminActions(): bool { if ($this->ip === null) { return true; } $allowedAdminRanges = $this->config->getSystemValue(self::SETTING_NAME, false); // Don't apply restrictions on empty or invalid configuration if ( $allowedAdminRanges === false || !is_array($allowedAdminRanges) || empty($allowedAdminRanges) ) { return true; } foreach ($allowedAdminRanges as $allowedAdminRange) { if ((new Range($allowedAdminRange))->contains($this->ip)) { return true; } } return false; } public function __toString(): string { return (string)$this->ip; } }