Code Duplication    Length = 26-28 lines in 2 locations

src/Backup/Sync/Copycom.php 1 location

@@ 66-91 (lines=26) @@
63
     * @param  array $config
64
     * @throws \phpbu\App\Backup\Sync\Exception
65
     */
66
    public function setup(array $config)
67
    {
68
        if (!class_exists('\\Barracuda\\Copy\\API')) {
69
            throw new Exception('Copy api not loaded: use composer "barracuda/copy": "1.1.*" to install');
70
        }
71
        if (!Arr::isSetAndNotEmptyString($config, 'app.key')) {
72
            throw new Exception('API access key is mandatory');
73
        }
74
        if (!Arr::isSetAndNotEmptyString($config, 'app.secret')) {
75
            throw new Exception('API access secret is mandatory');
76
        }
77
        if (!Arr::isSetAndNotEmptyString($config, 'user.key')) {
78
            throw new Exception('User access key is mandatory');
79
        }
80
        if (!Arr::isSetAndNotEmptyString($config, 'user.secret')) {
81
            throw new Exception('User access secret is mandatory');
82
        }
83
        if (!Arr::isSetAndNotEmptyString($config, 'path')) {
84
            throw new Exception('copy.com path is mandatory');
85
        }
86
        $this->appKey     = $config['app.key'];
87
        $this->appSecret  = $config['app.secret'];
88
        $this->userKey    = $config['user.key'];
89
        $this->userSecret = $config['user.secret'];
90
        $this->path       = Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path']));
91
    }
92
93
    /**
94
     * (non-PHPDoc)

src/Backup/Sync/SoftLayer.php 1 location

@@ 68-95 (lines=28) @@
65
     * @param  array $config
66
     * @throws \phpbu\App\Backup\Sync\Exception
67
     */
68
    public function setup(array $config)
69
    {
70
        if (!class_exists('\\ObjectStorage')) {
71
            throw new Exception('SoftLayer SDK not loaded: use composer "softlayer/objectstorage": "dev-master" to install');
72
        }
73
        if (!Arr::isSetAndNotEmptyString($config, 'user')) {
74
            throw new Exception('SoftLayer user is mandatory');
75
        }
76
        if (!Arr::isSetAndNotEmptyString($config, 'secret')) {
77
            throw new Exception('SoftLayer password is mandatory');
78
        }
79
        if (!Arr::isSetAndNotEmptyString($config, 'container')) {
80
            throw new Exception('SoftLayer container name is mandatory');
81
        }
82
        if (!Arr::isSetAndNotEmptyString($config, 'host')) {
83
            throw new Exception('SoftLayer host is mandatory');
84
        }
85
        if (!Arr::isSetAndNotEmptyString($config, 'path')) {
86
            throw new Exception('SoftLayer path is mandatory');
87
        }
88
        $this->user      = $config['user'];
89
        $this->secret    = $config['secret'];
90
        $this->container = $config['container'];
91
        $this->host      = $config['host'];
92
        $this->path      = Str::withLeadingSlash(
93
            Str::withTrailingSlash(Str::replaceDatePlaceholders($config['path']))
94
        );
95
    }
96
97
    /**
98
     * (non-PHPDoc)