ImageServiceHelper.php 1.93 KB
<?php

namespace common\helpers;

use Resource\ImageService;

/**
 * Class ImageServiceHelper
 * @package app\common\helpers
 */
class ImageServiceHelper
{
    /** @var **/
    private static $service;

    /**
     * @return ImageService
     */
    private static function getService()
    {
        if(null === self::$service){
            self::$service = new ImageService();
        }

       return  self::$service;
    }

    /**
     * @param $path
     * @param $destPath
     * @return mixed
     */
    public static function add($path, $destPath)
    {
        $service = self::getService();
        return $service->add($path, $destPath);
    }

    /**
     * @param $path
     * @param null $style
     * @return mixed
     */
    public static function getUrl($path, $style = null)
    {
        $service = self::getService();
        return $service->getUrl($path, $style);
    }

    /**
     * @param $path
     * @return mixed
     */
    public static function delete($path)
    {
        $service = self::getService();
        return $service->delete($path);
    }

    /**
     * @param $oldPath
     * @param $newPath
     * @return mixed
     */
    public static function replace($oldPath, $newPath, $tmpPath)
    {
        $service = self::getService();
        return $service->replace($oldPath, $newPath, $tmpPath);
    }

    /**
     * @param $path
     * @return mixed
     */
    public static function exists($path)
    {
        $service = self::getService();
        return $service->exists($path);
    }

    /**
     * @param $oldPath
     * @param $newPath
     * @return mixed
     */
    public static function move($oldPath, $newPath)
    {
        $service = self::getService();
        $service->move($oldPath, $newPath);
    }

    /**
     * @param $paths
     * @return mixed
     */
    public static function batchDelete($paths)
    {
        $service = self::getService();
        return $service->batchDelete($paths);
    }
}