Completed
Push — master ( fc6d38...1d5030 )
by Luke
05:23
created

ServiceProvider::boot()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
crap 12
1
<?php
2
/**
3
 * Laravel Cache Adapter for AWS Credential Caching.
4
 *
5
 * @author    Luke Waite <[email protected]>
6
 * @copyright 2017 Luke Waite
7
 * @license   http://www.opensource.org/licenses/mit-license.php MIT
8
 *
9
 * @link      https://github.com/lukewaite/laravel-aws-cache-adapter
10
 */
11
12
namespace LukeWaite\LaravelAwsCacheAdapter;
13
14
use Illuminate\Cache\CacheManager;
15
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
16
17
class ServiceProvider extends BaseServiceProvider
18
{
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function register()
23
    {
24
        //
25
    }
26
27
    /**
28
     * Bootstrap any application services.
29
     *
30
     * @return void
31
     */
32
    public function boot(CacheManager $manager)
33
    {
34
        $this->publishes([
35
            __DIR__ . '/../config/laravel-aws-cache.php' => config_path('laravel-aws-cache.php')
36
        ]);
37
38
        if (config('laravel-aws-cache.enable') && !empty(config('laravel-aws-cache.filesystems'))) {
39
            $this->insertCredentialSetting($manager);
40
        }
41
    }
42
43
    protected function insertCredentialSetting(CacheManager $manager)
44
    {
45
        collect(explode(',', config('laravel-aws-cache.filesystems')))
46
            ->each(function ($filesystem) use ($manager) {
47
                config([
48
                    'filesystems.disks.' . $filesystem . '.credentials',
49
                    new LaravelCacheAdapter($manager, config('laravel-aws-cache.cache'), $filesystem)
50
                ]);
51
            });
52
    }
53
}
54