Pop\Auth\Auth::setBlockedSubnets PHP Method

setBlockedSubnets() public method

Method to set the block subnets
public setBlockedSubnets ( string | array $subnets = null ) : Auth
$subnets string | array
return Auth
    public function setBlockedSubnets($subnets = null)
    {
        if (null === $subnets) {
            $this->validators['blockedSubnets'] = null;
        } else {
            $validSubnets = $this->filterSubnets($subnets);
            if (count($validSubnets) > 0) {
                $this->validators['blockedSubnets'] = new Validator\Excluded($validSubnets);
            }
        }
        return $this;
    }

Usage Example

示例#1
0
 public function testSetBlockedSubnets()
 {
     $a = new Auth(new File(__DIR__ . '/../tmp/access.txt'));
     $a->setBlockedSubnets(array('123.123.123', '124.124.124'));
     $this->assertEquals(array('123.123.123', '124.124.124'), $a->getValidator('blockedSubnets')->getValue());
     $a->setBlockedSubnets();
     $this->assertEquals(null, $a->getValidator('blockedSubnets'));
 }