ServiceProvider::boot()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 2
crap 6
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\Config\Repository;
16
use Illuminate\Support\ServiceProvider as BaseServiceProvider;
17
18
class ServiceProvider extends BaseServiceProvider
19
{
20
    /**
21
     * {@inheritdoc}
22
     */
23
    public function register()
24
    {
25
        //
26
    }
27
28
    /**
29
     * Bootstrap any application services.
30
     *
31
     * @param CacheManager $manager
32
     * @param Repository $config
33
     * @return void
34
     */
35
    public function boot(CacheManager $manager, Repository $config)
36
    {
37
        $this->publishes([
38
            __DIR__ . '/../config/laravel-aws-cache.php' => config_path('laravel-aws-cache.php')
39
        ]);
40
41
        if (config('laravel-aws-cache.enable')) {
42
            $this->insertCredentialSetting($manager, $config);
43
        }
44
    }
45
46
    protected function insertCredentialSetting(CacheManager $manager, Repository $config)
47
    {
48 View Code Duplication
        if (!empty(config('laravel-aws-cache.filesystems'))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
49
            collect(explode(',', config('laravel-aws-cache.filesystems')))
50
                ->each(function ($filesystem) use ($manager, $config) {
51
                    $config->set([
52
                        'filesystems.disks.' . $filesystem . '.credentials' =>
53
                            new LaravelCacheAdapter($manager, config('laravel-aws-cache.cache'))
54
                    ]);
55
                });
56
        }
57
58 View Code Duplication
        if (!empty(config('laravel-aws-cache.queues'))) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
59
            collect(explode(',', config('laravel-aws-cache.queues')))
60
                ->each(function ($queue) use ($manager, $config) {
61
                    $config->set([
62
                        'queue.connections.' . $queue . '.credentials' =>
63
                            new LaravelCacheAdapter($manager, config('laravel-aws-cache.cache'))
64
                    ]);
65
                });
66
        }
67
    }
68
}
69