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.
Completed
Branch master (70f706)
by Navarr
02:05 queued 19s
created

EchoServer   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 27.59 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 2
dl 8
loc 29
rs 10
c 0
b 0
f 0

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
// run composer install in top directory
4
require_once __DIR__.'/../vendor/autoload.php';
5
6
use Navarr\Socket\Server;
7
use Navarr\Socket\Socket;
8
9
class EchoServer extends Server
10
{
11
    const DEFAULT_PORT = 7;
12
13
    public function __construct($address = null, $port = self::DEFAULT_PORT)
14
    {
15
        parent::__construct($address, $port);
16
        $this->addHook(Server::HOOK_CONNECT, [$this, 'onConnect']);
17
        $this->addHook(Server::HOOK_INPUT, [$this, 'onInput']);
18
        $this->addHook(Server::HOOK_DISCONNECT, [$this, 'onDisconnect']);
19
        $this->run();
20
    }
21
22
    public function onConnect(Server $server, Socket $client, $message)
23
    {
24
        echo 'Connection Established', "\n";
25
    }
26
27
    public function onInput(Server $server, Socket $client, $message)
28
    {
29
        echo 'Received "', $message, '"', "\n";
30
        $client->write($message, strlen($message));
31
    }
32
33
    public function onDisconnect(Server $server, Socket $client, $message)
34
    {
35
        echo 'Disconnection', "\n";
36
    }
37
}
38
39
$server = new EchoServer('0.0.0.0');
40