Completed
Push — master ( 5bda77...cb2c73 )
by Aleh
10s
created

SocketOutput::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 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
        if (is_array($message)) {
22
            $message = implode("\n", $message);
23
        }
24
        return $this->client->write($message);
25
    }
26
27
    public function writeln($message, $options = 0)
28
    {
29
        return $this->client->write($message . "\n");
30
    }
31
32
    public function disconnect()
33
    {
34
        return $this->client->close();
35
    }
36
37
    private $client;
38
}
39