70 static $validKeys = [
'IPAddresses' ];
71 static $neededKeys = [
'IPAddresses' ];
73 $keys = array_keys( $restrictions );
74 $invalidKeys = array_diff(
$keys, $validKeys );
76 throw new InvalidArgumentException(
77 'Array contains invalid keys: ' . implode(
', ', $invalidKeys )
80 $missingKeys = array_diff( $neededKeys,
$keys );
82 throw new InvalidArgumentException(
83 'Array is missing required keys: ' . implode(
', ', $missingKeys )
87 if ( !is_array( $restrictions[
'IPAddresses'] ) ) {
88 throw new InvalidArgumentException(
'IPAddresses is not an array' );
90 foreach ( $restrictions[
'IPAddresses'] as $ip ) {
91 if ( !\IP::isIPAddress( $ip ) ) {
92 throw new InvalidArgumentException(
"Invalid IP address: $ip" );
95 $this->ipAddresses = $restrictions[
'IPAddresses'];