Ejemplo n.º 1
0
 /**
  * Constructor
  *
  * @see FileObject::__construct()
  * @see SplFileObject::__construct()
  * @param string $filename
  * @param string $open_mode
  * @param bool $use_include_path
  * @param resource $context
  * @access public
  */
 public function __construct($filename, $open_mode = 'r', $use_include_path = false, $context = null)
 {
     parent::__construct($filename, $open_mode, $use_include_path, $context);
     if (!$this->isImage() && !$this->isTemp()) {
         throw new UnexpectedValueException('File is not an image');
     }
 }
 public function testMimeAliases()
 {
     $image_file_obj = new FileObject($this->getTestFileByBaseName('photo.jpg'));
     $text_file_obj = FileObject::createFromBuffer('test and stuff');
     $this->assertTrue($image_file_obj->isImage());
     $this->assertFalse($text_file_obj->isImage());
     $this->assertTrue($text_file_obj->isText());
     $this->assertFalse($image_file_obj->isText());
 }