Completed
Push — master ( 279d4e...5d09e0 )
by Elf
02:49
created

ClientServiceProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 0
cts 24
cp 0
rs 10
c 0
b 0
f 0
wmc 5
lcom 1
cbo 3

4 Methods

Rating   Name   Duplication   Size   Complexity  
A boot() 0 4 1
A register() 0 6 1
A registerAgent() 0 10 2
A registerClient() 0 8 1
1
<?php
2
3
namespace ElfSundae\Laravel\Support\Providers;
4
5
use ElfSundae\Laravel\Support\Client;
6
use Jenssegers\Agent\Agent;
7
use Illuminate\Support\ServiceProvider;
8
9
class ClientServiceProvider extends ServiceProvider
10
{
11
    /**
12
     * Bootstrap the service provider.
13
     */
14
    public function boot()
15
    {
16
        $this->app['view']->share('client', $this->app['client']);
17
    }
18
19
    /**
20
     * Register the service provider.
21
     */
22
    public function register()
23
    {
24
        $this->registerAgent();
25
26
        $this->registerClient();
27
    }
28
29
    /**
30
     * Register the Agent.
31
     */
32
    protected function registerAgent()
33
    {
34
        if (! $this->app->bound('agent')) {
35
            $this->app->singleton('agent', function () {
36
                return new Agent;
37
            });
38
39
            $this->app->alias('agent', Agent::class);
40
        }
41
    }
42
43
    /**
44
     * Register the Client.
45
     */
46
    protected function registerClient()
47
    {
48
        $this->app->singleton('client', function () {
49
            return new Client;
50
        });
51
52
        $this->app->alias('client', Client::class);
53
    }
54
}
55