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

Dripper::getHtmlAttribute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
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