Completed
Pull Request — master (#39)
by
unknown
01:34
created

JsProvider::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php namespace Understand\UnderstandLaravel5;
2
3
use Illuminate\Foundation\Application;
4
use Understand\UnderstandLaravel5\Facades\UnderstandFieldProvider;
5
6
class JsProvider
7
{
8
    /**
9
     * @var Application
10
     */
11
    protected $app;
12
13
    /**
14
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
15
     */
16
    public function __construct(Application $app)
17
    {
18
        $this->app = $app;
19
    }
20
21
    /**
22
     * Get the Url of the JS bundle
23
     *
24
     * @return string
25
     */
26
    public function getJsBundleUrl()
27
    {
28
        return $this->app['config']->get('understand-laravel.cdn', 'https://cdn.understand.io/understand-js/beta/bundle.min.js');
29
    }
30
31
    /**
32
     * Get the JS configuration
33
     *
34
     * @return array
35
     */
36
    public function getJsConfig()
37
    {
38
        return [
39
            'env' => UnderstandFieldProvider::getEnvironment(),
40
            'token' => $this->app['config']->get('understand-laravel.token'),
41
            'context' => [
42
                'session_id' => UnderstandFieldProvider::getSessionId(),
43
                'request_id' => UnderstandFieldProvider::getProcessIdentifier(),
44
                'user_id' => UnderstandFieldProvider::getUserId(),
45
                'client_ip' => UnderstandFieldProvider::getClientIp()
46
            ]
47
        ];
48
    }
49
}