Completed
Push — master ( bc43b8...2257d3 )
by Aivis
01:41
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
    /**
10
     * JS bundle version
11
     */
12
    const DEFAULT_BUNDLE_VERSION = 'v1';
13
14
    /**
15
     * @var Application
16
     */
17
    protected $app;
18
19
    /**
20
     * @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...
21
     */
22
    public function __construct(Application $app)
23
    {
24
        $this->app = $app;
25
    }
26
27
    /**
28
     * Get the Url of the JS bundle
29
     *
30
     * @return string
31
     */
32
    public function getJsBundleUrl()
33
    {
34
        return $this->app['config']->get('understand-laravel.cdn', 'https://cdn.understand.io/understand-js/' . self::DEFAULT_BUNDLE_VERSION . '/bundle.min.js');
35
    }
36
37
    /**
38
     * Get the JS configuration
39
     *
40
     * @return array
41
     */
42
    public function getJsConfig()
43
    {
44
        return [
45
            'env' => UnderstandFieldProvider::getEnvironment(),
46
            'token' => $this->app['config']->get('understand-laravel.token'),
47
            'context' => [
48
                'session_id' => UnderstandFieldProvider::getSessionId(),
49
                'request_id' => UnderstandFieldProvider::getProcessIdentifier(),
50
                'user_id' => UnderstandFieldProvider::getUserId(),
51
                'client_ip' => UnderstandFieldProvider::getClientIp()
52
            ]
53
        ];
54
    }
55
}