upgrade zend (#1559)
[openemr.git] / vendor / zendframework / zend-validator / src / File / IsImage.php
blob9f80d0d3b09c72f02e665ef8811b9704394d0341
1 <?php
2 /**
3 * Zend Framework (http://framework.zend.com/)
5 * @link http://github.com/zendframework/zf2 for the canonical source repository
6 * @copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
7 * @license http://framework.zend.com/license/new-bsd New BSD License
8 */
10 namespace Zend\Validator\File;
12 use Traversable;
13 use Zend\Stdlib\ArrayUtils;
15 /**
16 * Validator which checks if the file is an image
18 class IsImage extends MimeType
20 /**
21 * @const string Error constants
23 const FALSE_TYPE = 'fileIsImageFalseType';
24 const NOT_DETECTED = 'fileIsImageNotDetected';
25 const NOT_READABLE = 'fileIsImageNotReadable';
27 /**
28 * @var array Error message templates
30 protected $messageTemplates = [
31 self::FALSE_TYPE => "File is no image, '%type%' detected",
32 self::NOT_DETECTED => "The mimetype could not be detected from the file",
33 self::NOT_READABLE => "File is not readable or does not exist",
36 /**
37 * Sets validator options
39 * @param array|Traversable|string $options
41 public function __construct($options = [])
43 // http://www.iana.org/assignments/media-types/media-types.xhtml#image
44 $default = [
45 'application/cdf',
46 'application/dicom',
47 'application/fractals',
48 'application/postscript',
49 'application/vnd.hp-hpgl',
50 'application/vnd.oasis.opendocument.graphics',
51 'application/x-cdf',
52 'application/x-cmu-raster',
53 'application/x-ima',
54 'application/x-inventor',
55 'application/x-koan',
56 'application/x-portable-anymap',
57 'application/x-world-x-3dmf',
58 'image/bmp',
59 'image/c',
60 'image/cgm',
61 'image/fif',
62 'image/gif',
63 'image/jpeg',
64 'image/jpm',
65 'image/jpx',
66 'image/jp2',
67 'image/naplps',
68 'image/pjpeg',
69 'image/png',
70 'image/svg',
71 'image/svg+xml',
72 'image/tiff',
73 'image/vnd.adobe.photoshop',
74 'image/vnd.djvu',
75 'image/vnd.fpx',
76 'image/vnd.net-fpx',
77 'image/x-cmu-raster',
78 'image/x-cmx',
79 'image/x-coreldraw',
80 'image/x-cpi',
81 'image/x-emf',
82 'image/x-ico',
83 'image/x-icon',
84 'image/x-jg',
85 'image/x-ms-bmp',
86 'image/x-niff',
87 'image/x-pict',
88 'image/x-pcx',
89 'image/x-png',
90 'image/x-portable-anymap',
91 'image/x-portable-bitmap',
92 'image/x-portable-greymap',
93 'image/x-portable-pixmap',
94 'image/x-quicktime',
95 'image/x-rgb',
96 'image/x-tiff',
97 'image/x-unknown',
98 'image/x-windows-bmp',
99 'image/x-xpmi',
102 if ($options instanceof Traversable) {
103 $options = ArrayUtils::iteratorToArray($options);
106 if ($options === null) {
107 $options = [];
110 parent::__construct($options);
112 if (! $this->getMimeType()) {
113 $this->setMimeType($default);