71 static $validKeys = [
'IPAddresses' ];
72 static $neededKeys = [
'IPAddresses' ];
74 $keys = array_keys( $restrictions );
75 $invalidKeys = array_diff(
$keys, $validKeys );
77 throw new InvalidArgumentException(
78 'Array contains invalid keys: ' . implode(
', ', $invalidKeys )
81 $missingKeys = array_diff( $neededKeys,
$keys );
83 throw new InvalidArgumentException(
84 'Array is missing required keys: ' . implode(
', ', $missingKeys )
88 if ( !is_array( $restrictions[
'IPAddresses'] ) ) {
89 throw new InvalidArgumentException(
'IPAddresses is not an array' );
91 foreach ( $restrictions[
'IPAddresses'] as $ip ) {
92 if ( !IPUtils::isIPAddress( $ip ) ) {
93 throw new InvalidArgumentException(
"Invalid IP address: $ip" );
96 $this->ipAddresses = $restrictions[
'IPAddresses'];