File indexing completed on 2025-01-26 05:29:15

0001 <?php
0002 
0003 namespace Intervention\Image;
0004 
0005 use Closure;
0006 
0007 class ImageManagerStatic
0008 {
0009     /**
0010      * Instance of Intervention\Image\ImageManager
0011      *
0012      * @var ImageManager
0013      */
0014     public static $manager;
0015 
0016     /**
0017      * Creates a new instance
0018      *
0019      * @param ImageManager $manager
0020      */
0021     public function __construct(ImageManager $manager = null)
0022     {
0023         self::$manager = $manager ? $manager : new ImageManager;
0024     }
0025 
0026     /**
0027      * Get or create new ImageManager instance
0028      *
0029      * @return ImageManager
0030      */
0031     public static function getManager()
0032     {
0033         return self::$manager ? self::$manager : new ImageManager;
0034     }
0035 
0036     /**
0037      * Statically create new custom configured image manager
0038      *
0039      * @param  array $config
0040      *
0041      * @return ImageManager
0042      */
0043     public static function configure(array $config = [])
0044     {
0045         return self::$manager = self::getManager()->configure($config);
0046     }
0047 
0048     /**
0049      * Statically initiates an Image instance from different input types
0050      *
0051      * @param  mixed $data
0052      *
0053      * @return \Intervention\Image\Image
0054      */
0055     public static function make($data)
0056     {
0057         return self::getManager()->make($data);
0058     }
0059 
0060     /**
0061      * Statically creates an empty image canvas
0062      *
0063      * @param  int   $width
0064      * @param  int   $height
0065      * @param  mixed $background
0066      *
0067      * @return \Intervention\Image\Image
0068      */
0069     public static function canvas($width, $height, $background = null)
0070     {
0071         return self::getManager()->canvas($width, $height, $background);
0072     }
0073 
0074     /**
0075      * Create new cached image and run callback statically
0076      *
0077      * @param  Closure  $callback
0078      * @param  int      $lifetime
0079      * @param  boolean  $returnObj
0080      *
0081      * @return mixed
0082      */
0083     public static function cache(Closure $callback, $lifetime = null, $returnObj = false)
0084     {
0085         return self::getManager()->cache($callback, $lifetime, $returnObj);
0086     }
0087 }