PingParser::parse()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
/**
4
 * Ping for Laravel.
5
 *
6
 * This class makes Ping request to a host.
7
 *
8
 * Ping uses the ICMP protocol's mandatory ECHO_REQUEST datagram to elicit an ICMP ECHO_RESPONSE from a host or gateway.
9
 *
10
 * @author  Angel Campos <[email protected]>
11
 *
12
 * @requires PHP 8.0
13
 *
14
 * @version  2.1.2
15
 */
16
17
namespace Acamposm\Ping\Parsers;
18
19
use Acamposm\Ping\Interfaces\PingParserInterface;
20
21
class PingParser implements PingParserInterface
22
{
23
    protected string $host_status = '';
24
    protected array $sequence = [];
25
    protected array $statistics = [];
26
    protected array $round_trip_time = [];
27
28
    /**
29
     * PingParser constructor.
30
     *
31
     * @param array $results
32
     */
33
    public function __construct(protected array $results = [])
34
    {
35
    }
36
37
    /**
38
     * Returns the Ping execution result parsed as object.
39
     *
40
     * @return object
41
     */
42
    public function parse(): object
43
    {
44
        return (object) $this->results;
45
    }
46
}
47