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

ClientServiceProvider::boot()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 4
ccs 0
cts 4
cp 0
crap 2
rs 10
c 0
b 0
f 0
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