Completed
Push — master ( 140926...9ed9ef )
by Tyler
03:25
created

Host::getHost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
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 15
    public function __construct($host)
16
    {
17 15
        $this->host = $host;
18 15
        $this->pinger = new Ping($host);
19 15
    }
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 3
    public function ping(){
26 3
        $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 3
        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
    /**
43
     * Gets the value of host.
44
     *
45
     * @return mixed
46
     */
47 3
    public function getHost()
48
    {
49 3
        return $this->host;
50
    }
51
52
    /**
53
     * Gets the value of ping.
54
     *
55
     * @return mixed
56
     */
57 6
    public function getPing()
58
    {
59 6
        return $this->ping;
60
    }
61
62
    /**
63
     * Gets the value of statusCode.
64
     *
65
     * @return mixed
66
     */
67 3
    public function getStatusCode()
68
    {
69 3
        return $this->statusCode;
70
    }
71
}