<?php
namespace App\Lib\Ccwl\Oss;

class CcwlOssManager 
{   
    private $currentDriver = '';
    
    private $validDrivers = ['Aliyun'];

    const DRIVER_ALIYUN = "Aliyun";

    /**
     * 橙橙网络封装OSS client
     * 
     * @param string $oss_access_id
     * @param string $oss_access_key
     * @param string $oss_endpoint
     * @param string $oss_bucket
     * 
     * @return null
     */
    public function __construct($driver)
    {
        $driver = ucfirst(strtolower($driver));
        if (!in_array($driver, $this->validDrivers)) {
            exit(__CLASS__ . " 暂不支持OSS驱动 " . $driver);
        }
        $this->currentDriver = $driver;        
    }

    public function init($config)
    {
        if ($this->currentDriver == self::DRIVER_ALIYUN) {
            return new AliyunOssDriver($config);
        }
        return null;
    }
}
