Pop\File\File::setMime PHP Method

setMime() public method

Set the file mime type.
public setMime ( string $mime ) : File
$mime string
return File
    public function setMime($mime)
    {
        if (count($this->allowed) > 0 && !in_array($mime, $this->allowed)) {
            throw new Exception('Error: The file mime type ' . $mime . ' is not an accepted file mime type.');
        }
        $this->mime = $mime;
        return $this;
    }

Usage Example

Example #1
0
 public function testSetMimeException()
 {
     $this->setExpectedException('Pop\\File\\Exception');
     $f = new File('accesslog.txt');
     $f->setMime('bad/mime');
 }