JsProvider   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 50
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getJsBundleUrl() 0 4 1
A getJsConfig() 0 13 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
}