Pop\File\File::isAllowed PHP Method

isAllowed() public method

Test if a certain file type is allowed.
public isAllowed ( string $type ) : boolean
$type string
return boolean
    public function isAllowed($type)
    {
        return array_key_exists(strtolower($type), $this->allowed);
    }

Usage Example

Example #1
0
 public function testAllowedTypes()
 {
     $f = new File(__DIR__ . '/../tmp/access.txt', array('txt' => 'text/plain'));
     $this->assertFalse($f->isAllowed('php'));
     $this->assertTrue(is_array($f->getAllowedTypes()));
     $f->setAllowedTypes(array('txt' => 'text/plain', 'php' => 'text/plain'));
     $f->addAllowedTypes(array('sql' => 'text/plain'));
     $this->assertTrue($f->isAllowed('php'));
 }