Completed
Push — master ( 11f9a0...c74065 )
by ARCANEDEV
9s
created

GravatarServiceProvider::publishConfig()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 6
ccs 5
cts 5
cp 1
rs 9.4285
cc 1
eloc 4
nc 1
nop 0
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
     * Vendor name.
19
     *
20
     * @var string
21
     */
22
    protected $vendor  = 'arcanedev';
23
24
    /**
25
     * Package name.
26
     *
27
     * @var string
28
     */
29
    protected $package = 'gravatar';
30
31
    /**
32
     * Indicates if loading of the provider is deferred.
33
     *
34
     * @var bool
35
     */
36
    protected $defer   = true;
37
38
    /* ------------------------------------------------------------------------------------------------
39
     |  Getters & Setters
40
     | ------------------------------------------------------------------------------------------------
41
     */
42
    /**
43
     * Get the base path of the package.
44
     *
45
     * @return string
46
     */
47 228
    public function getBasePath()
48
    {
49 228
        return dirname(__DIR__);
50
    }
51
52
    /* ------------------------------------------------------------------------------------------------
53
     |  Main Functions
54
     | ------------------------------------------------------------------------------------------------
55
     */
56
    /**
57
     * Register the service provider.
58
     */
59 228
    public function register()
60
    {
61 228
        $this->registerConfig();
62 228
        $this->registerGravatar();
63 228
    }
64
65
    /**
66
     * Boot the service provider.
67
     */
68 228
    public function boot()
69
    {
70 228
        $this->publishConfig();
0 ignored issues
show
Documentation Bug introduced by
The method publishConfig does not exist on object<Arcanedev\Gravata...ravatarServiceProvider>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
71 228
    }
72
73
    /**
74
     * Get the services provided by the provider.
75
     *
76
     * @return array
77
     */
78 24
    public function provides()
79
    {
80
        return [
81 24
            'arcanedev.gravatar',
82 18
            Contracts\Gravatar::class,
83 18
        ];
84
    }
85
86
    /* ------------------------------------------------------------------------------------------------
87
     |  Other Functions
88
     | ------------------------------------------------------------------------------------------------
89
     */
90
    /**
91
     * Register Gravatar Helper.
92
     */
93
    private function registerGravatar()
94
    {
95 228
        $this->singleton('arcanedev.gravatar', function($app) {
96
            /** @var \Illuminate\Config\Repository $config */
97 192
            $config = $app['config'];
98
99 192
            return new Gravatar(
100 192
                $config->get('gravatar.default', 'mm'),
101 192
                $config->get('gravatar.size', 80),
102 192
                $config->get('gravatar.max-rating', 'g')
103 144
            );
104 228
        });
105
106 228
        $this->bind(Contracts\Gravatar::class, 'arcanedev.gravatar');
107 228
    }
108
}
109