GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Client   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 77
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 8
lcom 1
cbo 0
dl 0
loc 77
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getRouterClient() 0 4 1
A getActives() 0 4 1
A getScripts() 0 4 1
A execute() 0 15 3
A lastResponse() 0 4 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace LosRouterOs;
6
7
use PEAR2\Net\RouterOS\Client as RouterClient;
8
use PEAR2\Net\RouterOS\Request;
9
use PEAR2\Net\RouterOS\Response;
10
use PEAR2\Net\RouterOS\ResponseCollection;
11
12
class Client
13
{
14
    /** @var RouterClient */
15
    private $routerClient;
16
17
    /** @var ResponseCollection */
18
    private $lastResponse;
19
20
    /**
21
     * Client constructor.
22
     * @param string $host
23
     * @param string $username
24
     * @param string $password
25
     * @param int $port
26
     * @param int $timeout
27
     */
28
    public function __construct(string $host, string $username, string $password, int $port = 8727, int $timeout = 60)
29
    {
30
        $this->routerClient = new RouterClient(
31
            $host,
32
            $username,
33
            $password,
34
            $port,
35
            false,
36
            $timeout
37
        );
38
    }
39
40
    /**
41
     * @return RouterClient
42
     */
43
    public function getRouterClient()
44
    {
45
        return $this->routerClient;
46
    }
47
48
    /**
49
     * @return array
50
     */
51
    public function getActives()
52
    {
53
        return $this->execute('/ip hotspot active print');
54
    }
55
56
    public function getScripts()
57
    {
58
        return $this->execute('/system script print');
59
    }
60
61
    /**
62
     * @param string $command
63
     * @return array
64
     */
65
    public function execute(string $command)
66
    {
67
        $request = new Request($command);
68
        $this->lastResponse = $this->routerClient->sendSync($request);
69
70
        $list = [];
71
        /** @var Response $response */
72
        foreach ($this->lastResponse as $response) {
73
            if ($response->getType() == Response::TYPE_DATA) {
74
                $list[] = $response->getIterator();
75
            }
76
        }
77
78
        return $list;
79
    }
80
81
    /**
82
     * @return ResponseCollection
83
     */
84
    public function lastResponse(): ResponseCollection
85
    {
86
        return $this->lastResponse;
87
    }
88
}
89