ConfigServiceProvider::configureEmailRecipients()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 13
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 13
rs 9.4285
1
<?php
2
3
namespace App\Providers;
4
5
use Exception;
6
use Illuminate\Support\ServiceProvider;
7
use Illuminate\Cache\MemcachedConnector;
8
9
class ConfigServiceProvider extends ServiceProvider
10
{
11
    public function register()
12
    {
13
        $this->configureAuthorization();
14
        $this->configureCacheProvider();
15
        $this->configureEmailRecipients();
16
    }
17
18
    protected function configureAuthorization()
19
    {
20
        config()->set(
21
            'laravel-authorize.login_url',
22
            request()->isFront() ? 'login' : 'blender/login'
23
        );
24
    }
25
26
    protected function configureCacheProvider()
27
    {
28
        if (app()->environment('production') ||
29
            config()->get('cache.default') !== 'memcached'
30
        ) {
31
            return;
32
        }
33
34
        try {
35
            if (! class_exists('Memcached')) {
36
                throw new Exception();
37
            }
38
39
            (new MemcachedConnector())->connect(config('cache.stores.memcached.servers'));
40
        } catch (Exception $e) {
41
            config()->set('cache.default', 'array');
42
        }
43
    }
44
45
    protected function configureEmailRecipients()
46
    {
47
        if (app()->environment('production')) {
48
            return;
49
        }
50
51
        config()->set(
52
            'mail.recipients',
53
            collect(config('mail.recipients'))->map(function () {
54
                return '[email protected]';
55
            })
56
        );
57
    }
58
}
59