Pop\File\File::setAllowedTypes PHP Method

setAllowedTypes() public method

Set the allowed files types, overriding any previously allowed types.
public setAllowedTypes ( array $types = null ) : void
$types array
return void
    public function setAllowedTypes($types = null)
    {
        $this->allowed = array();
        $ary = null === $types || !is_array($types) ? array() : $types;
        $this->addAllowedTypes($ary);
    }

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'));
 }