SelectelServiceProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 3
c 2
b 0
f 0
lcom 0
cbo 4
dl 0
loc 30
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 16 2
A register() 0 4 1
1
<?php
2
3
namespace ArgentCrusade\Flysystem\Selectel;
4
5
use League\Flysystem\Filesystem;
6
use Illuminate\Support\Facades\Storage;
7
use Illuminate\Support\ServiceProvider;
8
use ArgentCrusade\Selectel\CloudStorage\CloudStorage;
9
use ArgentCrusade\Selectel\CloudStorage\Api\ApiClient;
10
11
class SelectelServiceProvider extends ServiceProvider
12
{
13
    /**
14
     * Bootstrap the application services.
15
     */
16
    public function boot()
17
    {
18
        Storage::extend('selectel', function ($app, $config) {
19
            $api = new ApiClient($config['username'], $config['password']);
20
            $api->authenticate();
21
22
            $storage = new CloudStorage($api);
23
            $container = $storage->getContainer($config['container']);
24
25
            if (isset($config['container_url'])) {
26
                $container->setUrl($config['container_url']);
27
            }
28
29
            return new Filesystem(new SelectelAdapter($container));
30
        });
31
    }
32
33
    /**
34
     * Register the application services.
35
     */
36
    public function register()
37
    {
38
        //
39
    }
40
}
41