Completed
Push — master ( d57705...140926 )
by Tyler
03:38 queued 01:04
created

Host::setHost()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

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 3
cp 0
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
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;
13
    protected $statusCode;
14
15 3
    public function __construct($host)
16
    {
17 3
        $this->host = $host;
18 3
        $this->pinger = new Ping($host);
19 3
    }
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();
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
    /**
43
     * Gets the value of host.
44
     *
45
     * @return mixed
46
     */
47
    public function getHost()
48
    {
49
        return $this->host;
50
    }
51
52
    /**
53
     * Sets the value of host.
54
     *
55
     * @param mixed $host the host
56
     *
57
     * @return self
58
     */
59
    protected function setHost($host)
60
    {
61
        $this->host = $host;
62
63
        return $this;
64
    }
65
66
    /**
67
     * Gets the value of pinger.
68
     *
69
     * @return mixed
70
     */
71
    public function getPinger()
72
    {
73
        return $this->pinger;
74
    }
75
76
    /**
77
     * Sets the value of pinger.
78
     *
79
     * @param mixed $pinger the pinger
80
     *
81
     * @return self
82
     */
83
    protected function setPinger(Ping $pinger)
84
    {
85
        $this->pinger = $pinger;
86
87
        return $this;
88
    }
89
90
    /**
91
     * Gets the value of ping.
92
     *
93
     * @return mixed
94
     */
95
    public function getPing()
96
    {
97
        return $this->ping;
98
    }
99
100
    /**
101
     * Gets the value of statusCode.
102
     *
103
     * @return mixed
104
     */
105
    public function getStatusCode()
106
    {
107
        return $this->statusCode;
108
    }
109
}