Completed
Pull Request — master (#5)
by ARCANEDEV
02:37
created

GravatarServiceProvider::getBasePath()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 2
cts 2
cp 1
crap 1
1
<?php namespace Arcanedev\Gravatar;
2
3
use Arcanedev\Support\PackageServiceProvider as ServiceProvider;
4
5
/**
6
 * Class     GravatarServiceProvider
7
 *
8
 * @package  Arcanedev\Gravatar
9
 * @author   ARCANEDEV <[email protected]>
10
 */
11
class GravatarServiceProvider extends ServiceProvider
12
{
13
    /* -----------------------------------------------------------------
14
     |  Properties
15
     | -----------------------------------------------------------------
16
     */
17
18
    /**
19
     * Package name.
20
     *
21
     * @var string
22
     */
23
    protected $package = 'gravatar';
24
25
    /**
26
     * Indicates if loading of the provider is deferred.
27
     *
28
     * @var bool
29
     */
30
    protected $defer   = true;
31
32
    /* -----------------------------------------------------------------
33
     |  Main Methods
34
     | -----------------------------------------------------------------
35
     */
36
37
    /**
38
     * Register the service provider.
39
     */
40 38
    public function register()
41
    {
42 38
        parent::register();
43
44 38
        $this->registerConfig();
45 38
        $this->registerGravatar();
46 38
    }
47
48
    /**
49
     * Boot the service provider.
50
     */
51 38
    public function boot()
52
    {
53 38
        parent::boot();
54
55 38
        $this->publishConfig();
56 38
    }
57
58
    /**
59
     * Get the services provided by the provider.
60
     *
61
     * @return array
62
     */
63 4
    public function provides()
64
    {
65
        return [
66 4
            Contracts\Gravatar::class,
67
        ];
68
    }
69
70
    /* -----------------------------------------------------------------
71
     |  Other Methods
72
     | -----------------------------------------------------------------
73
     */
74
75
    /**
76
     * Register Gravatar Helper.
77
     */
78
    private function registerGravatar()
79
    {
80 38
        $this->singleton(Contracts\Gravatar::class, function($app) {
81
            /** @var  \Illuminate\Contracts\Config\Repository  $config */
82 32
            $config = $app['config'];
83
84 32
            return new Gravatar(
85 32
                $config->get('gravatar.default', 'mm'),
86 32
                $config->get('gravatar.size', 80),
87 32
                $config->get('gravatar.max-rating', 'g')
88
            );
89 38
        });
90
    }
91
}
92