Overview

Namespaces

  • Faulancer
    • Controller
    • Exception
    • Form
      • Validator
        • Type
    • Helper
      • Reflection
    • Http
    • Mail
    • ORM
      • User
    • Service
      • Factory
    • ServiceLocator
    • Session
    • View
      • Helper

Classes

  • DateTime
  • Email
  • Image
  • Number
  • Text
  • Overview
  • Namespace
  • Class
 1:  2:  3:  4:  5:  6:  7:  8:  9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 
<?php
/**
 * Class Image
 * @package Faulancer\Form\Validator\Type
 */
namespace Faulancer\Form\Validator\Type;

use Faulancer\Form\Validator\AbstractValidator;

/**
 * Class Image
 */
class Image extends AbstractValidator
{

    /**
     * The error message as key for translation
     * @var string
     */
    protected $errorMessage = 'validator_invalid_image_type';

    /**
     * Valid image mime-types
     * @var array
     */
    private $validImageMimeTypes = [
        'image/jpg',
        'image/jpeg',
        'image/png',
        'image/gif',
        'image/tiff',
        'image/psd',
        'image/x-icon',
        'image/svg+xml'
    ];

    /**
     * Validate image type within it's mime-type
     * @param string $data
     * @return boolean
     */
    public function process($data)
    {
        if (!file_exists($data)) {
            return false;
        }

        $data = mime_content_type($data);
        return in_array($data, $this->validImageMimeTypes);
    }

}
API documentation generated by ApiGen