Completed
Push — master ( 303c2e...5c0c25 )
by Elf
03:15
created

AgentServiceProvider::aliasFacade()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
ccs 0
cts 8
cp 0
rs 9.4285
cc 2
eloc 5
nc 2
nop 2
crap 6
1
<?php
2
3
namespace ElfSundae\Laravel\Agent;
4
5
use Illuminate\Support\ServiceProvider;
6
7
class AgentServiceProvider extends ServiceProvider
8
{
9
    /**
10
     * Indicates if loading of the provider is deferred.
11
     *
12
     * @var bool
13
     */
14
    protected $defer = false;
15
16
    /**
17
     * Register the service provider.
18
     *
19
     * @return void
20
     */
21
    public function register()
22
    {
23
        $this->registerAgent();
24
25
        $this->registerClient();
26
    }
27
28
    /**
29
     * Register the Agent.
30
     *
31
     * @return void
32
     */
33
    protected function registerAgent()
34
    {
35
        $this->app->register(\Jenssegers\Agent\AgentServiceProvider::class);
36
37
        $this->app->alias('agent', \Jenssegers\Agent\Agent::class);
38
    }
39
40
    /**
41
     * Register the Client.
42
     *
43
     * @return void
44
     */
45
    protected function registerClient()
46
    {
47
        $this->app->singleton('agent.client', function ($app) {
48
            return (new Client)->setAgent($app->make('agent'));
49
        });
50
51
        $this->app->alias('agent.client', Client::class);
52
    }
53
}
54