Completed
Pull Request — master (#29)
by Aleh
02:51
created

SocketOutput   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 3
Bugs 0 Features 2
Metric Value
wmc 4
c 3
b 0
f 2
lcom 1
cbo 2
dl 0
loc 24
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A write() 0 4 1
A writeln() 0 4 1
A disconnect() 0 4 1
1
<?php
2
3
namespace Padawan\Framework\Application\Socket;
4
5
use Symfony\Component\Console\Output\OutputInterface;
6
use Symfony\Component\Console\Output\NullOutput;
7
use Amp\Socket\Client;
8
9
/**
10
 * Class SocketOutput
11
 */
12
class SocketOutput extends NullOutput
13
{
14
    public function __construct(Client $client)
15
    {
16
        $this->client = $client;
17
    }
18
19
    public function write($message, $newline = false, $options = 0)
20
    {
21
        return $this->client->write($message);
0 ignored issues
show
Bug introduced by
It seems like $message defined by parameter $message on line 19 can also be of type array; however, Amp\Socket\Client::write() does only seem to accept string, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
22
    }
23
24
    public function writeln($message, $options = 0)
25
    {
26
        return $this->client->write($message . "\n");
27
    }
28
29
    public function disconnect()
30
    {
31
        return $this->client->close();
32
    }
33
34
    private $client;
35
}
36