Completed
Push — stable ( 86ecc3...3a45ea )
by Nuno
07:34
created

FilesystemServiceProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 1
cbo 2
dl 0
loc 40
ccs 11
cts 11
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A register() 0 12 2
A getDefaultConfig() 0 12 1
1
<?php
2
3
/**
4
 * This file is part of Laravel Zero.
5
 *
6
 * (c) Nuno Maduro <[email protected]>
7
 *
8
 *  For the full copyright and license information, please view the LICENSE
9
 *  file that was distributed with this source code.
10
 */
11
12
namespace LaravelZero\Framework\Providers\Filesystem;
13
14
use Illuminate\Contracts\Filesystem\Filesystem;
15
use Illuminate\Filesystem\FilesystemServiceProvider as BaseServiceProvider;
16
17
/**
18
 * This is the Laravel Zero Framework Filesystem Service Provider implementation.
19
 */
20
class FilesystemServiceProvider extends BaseServiceProvider
21
{
22
    /**
23
     * Register Filesystem service.
24
     *
25
     * @return void
26
     */
27 21
    public function register(): void
28
    {
29 21
        parent::register();
30
31 21
        $this->app->alias('filesystem.disk', Filesystem::class);
32
33 21
        $config = $this->app->make('config');
34
35 21
        if ($config->get('filesystems.default') === null) {
36 21
            $config->set('filesystems', $this->getDefaultConfig());
37
        }
38 21
    }
39
40
    /**
41
     * Returns the default application filesystems config.
42
     *
43
     * We it simple we use the `local` driver.
44
     *
45
     * @return array
46
     */
47 21
    protected function getDefaultConfig(): array
48
    {
49
        return [
50 21
            'default' => 'local',
51
            'disks' => [
52
                'local' => [
53 21
                    'driver' => 'local',
54 21
                    'root' => $this->app->storagePath('app'),
55
                ],
56
            ],
57
        ];
58
    }
59
}
60