Completed
Push — master ( 9a7512...193d10 )
by Mike
03:58
created

Dripper   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 3
dl 0
loc 27
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getHtmlAttribute() 0 7 1
A getUrlAttribute() 0 8 1
A getIntervalAttribute() 0 5 1
1
<?php namespace GeneaLabs\LaravelMessenger;
2
3
use Jenssegers\Model\Model;
4
5
class Dripper extends Model
6
{
7
    public function getUrlAttribute() : string
8
    {
9
        return trim(config('genealabs-laravel-caffeine.domain', url('/')), '/')
10
            . '/'
11
            . trim(config(
12
                'genealabs-laravel-caffeine.route',
13
                'genealabs/laravel-caffeine/drip'
14
            ), '/');
15
    }
16
17
    public function getIntervalAttribute() : string
18
    {
19
        return config(
20
            'genealabs-laravel-caffeine.dripIntervalInMilliSeconds',
21
            300000
22
        );
23
    }
24
25
    public function getHtmlAttribute() : string
26
    {
27
        return '<script>setInterval(function(){'
28
            . "var e=window.XMLHttpRequest?new XMLHttpRequest:new ActiveXObject('Microsoft.XMLHTTP');"
29
            . "e.open('GET','{$this->url}',!0);"
0 ignored issues
show
Bug Best Practice introduced by
The property url does not exist on GeneaLabs\LaravelMessenger\Dripper. Since you implemented __get, consider adding a @property annotation.
Loading history...
30
            . "e.setRequestHeader('X-Requested-With','XMLHttpRequest');"
31
            . "e.send();}, {$this->interval});</script>";
0 ignored issues
show
Bug Best Practice introduced by
The property interval does not exist on GeneaLabs\LaravelMessenger\Dripper. Since you implemented __get, consider adding a @property annotation.
Loading history...
32
    }
33
}
34