Screen\Image\Types::getClass PHP Method

getClass() public static method

Returns an instance of the requested image type
public static getClass ( string $type ) : Type
$type string Image type
return Screen\Image\Types\Type
    public static function getClass($type)
    {
        if (!static::isAvailable($type)) {
            throw new \Exception("Invalid image format '{$type}'. " . "Allowed formats are: " . implode(', ', static::available()));
        }
        $className = static::$typesMap[strtolower($type)];
        return new $className();
    }

Usage Example

Example #1
0
 /**
  * Sets the image type
  *
  * @param string $type 'jpg', 'png', etc...
  *
  * @return Capture
  */
 public function setImageType($type)
 {
     $this->imageType = Types::getClass($type);
     return $this;
 }