Completed
Push — master ( 9ed9ef...a42617 )
by Tyler
02:57
created

Host::status()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 0
cts 6
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
3
namespace Tylercd100\ServerStatus;
4
5
use JJG\Ping;
6
use GuzzleHttp\Client;
7
8
class Host 
9
{
10
    protected $host;
11
    protected $pinger;
12
    protected $ping = 0;
13
    protected $statusCode = 0;
14
15
    public function __construct($host)
16
    {
17
        $this->host = $host;
18
        $this->pinger = new Ping($host);
19
    }
20
21
    /**
22
     * Checks the ping of the host
23
     * @return [type] [description]
0 ignored issues
show
Documentation introduced by
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
24
     */
25
    public function ping(){
26
        $this->ping = $this->pinger->ping();
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->pinger->ping() of type double or false is incompatible with the declared type integer of property $ping.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
27
        return $this->getPing();
28
    }
29
30
    /**
31
     * Checks the status of the host
32
     * @return [type] [description]
0 ignored issues
show
Documentation introduced by
The doc-type [type] could not be parsed: Unknown type name "" at position 0. [(view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
33
     */
34
    public function status(){
35
        $client = new Client();
36
        $res = $client->request('GET', $this->host);
37
        $this->statusCode = $res->getStatusCode();
38
        return $this->getStatusCode();
39
    }
40
41
    /**
42
     * Sets the value of pinger.
43
     *
44
     * @return void
45
     */
46
    public function setPinger(Ping $pinger)
47
    {
48
        $this->pinger = $pinger;
49
    }
50
51
    /**
52
     * Gets the value of host.
53
     *
54
     * @return mixed
55
     */
56
    public function getHost()
57
    {
58
        return $this->host;
59
    }
60
61
    /**
62
     * Gets the value of ping.
63
     *
64
     * @return mixed
65
     */
66
    public function getPing()
67
    {
68
        return $this->ping;
69
    }
70
71
    /**
72
     * Gets the value of statusCode.
73
     *
74
     * @return mixed
75
     */
76
    public function getStatusCode()
77
    {
78
        return $this->statusCode;
79
    }
80
}