Completed
Push — master ( c949aa...0764cf )
by Elf
02:34
created

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