| 1 |
<?php |
| 2 |
|
| 3 |
namespace Intervention\Image; |
| 4 |
|
| 5 |
use Closure; |
| 6 |
|
| 7 |
class ImageManagerStatic |
| 8 |
{ |
| 9 |
/** |
| 10 |
* Instance of Intervention\Image\ImageManager |
| 11 |
* |
| 12 |
* @var ImageManager |
| 13 |
*/ |
| 14 |
public static $manager; |
| 15 |
|
| 16 |
/** |
| 17 |
* Creates a new instance |
| 18 |
* |
| 19 |
* @param ImageManager $manager |
| 20 |
*/ |
| 21 |
public function __construct(ImageManager $manager = null) |
| 22 |
{ |
| 23 |
self::$manager = $manager ? $manager : new ImageManager; |
| 24 |
} |
| 25 |
|
| 26 |
/** |
| 27 |
* Get or create new ImageManager instance |
| 28 |
* |
| 29 |
* @return ImageManager |
| 30 |
*/ |
| 31 |
public static function getManager() |
| 32 |
{ |
| 33 |
return self::$manager ? self::$manager : new ImageManager; |
| 34 |
} |
| 35 |
|
| 36 |
/** |
| 37 |
* Statically create new custom configured image manager |
| 38 |
* |
| 39 |
* @param array $config |
| 40 |
* |
| 41 |
* @return ImageManager |
| 42 |
*/ |
| 43 |
public static function configure(array $config = []) |
| 44 |
{ |
| 45 |
return self::$manager = self::getManager()->configure($config); |
| 46 |
} |
| 47 |
|
| 48 |
/** |
| 49 |
* Statically initiates an Image instance from different input types |
| 50 |
* |
| 51 |
* @param mixed $data |
| 52 |
* |
| 53 |
* @return \Intervention\Image\Image |
| 54 |
* @throws \Intervention\Image\Exception\NotReadableException |
| 55 |
*/ |
| 56 |
public static function make($data) |
| 57 |
{ |
| 58 |
return self::getManager()->make($data); |
| 59 |
} |
| 60 |
|
| 61 |
/** |
| 62 |
* Statically creates an empty image canvas |
| 63 |
* |
| 64 |
* @param int $width |
| 65 |
* @param int $height |
| 66 |
* @param mixed $background |
| 67 |
* |
| 68 |
* @return \Intervention\Image\Image |
| 69 |
*/ |
| 70 |
public static function canvas($width, $height, $background = null) |
| 71 |
{ |
| 72 |
return self::getManager()->canvas($width, $height, $background); |
| 73 |
} |
| 74 |
|
| 75 |
/** |
| 76 |
* Create new cached image and run callback statically |
| 77 |
* |
| 78 |
* @param Closure $callback |
| 79 |
* @param int $lifetime |
| 80 |
* @param boolean $returnObj |
| 81 |
* |
| 82 |
* @return mixed |
| 83 |
*/ |
| 84 |
public static function cache(Closure $callback, $lifetime = null, $returnObj = false) |
| 85 |
{ |
| 86 |
return self::getManager()->cache($callback, $lifetime, $returnObj); |
| 87 |
} |
| 88 |
} |
| 89 |
|