AcceptedFrame::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
/**
3
 * Async sockets
4
 *
5
 * @copyright Copyright (c) 2015-2017, Efimov Evgenij <[email protected]>
6
 *
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
namespace AsyncSockets\Frame;
11
12
use AsyncSockets\Socket\SocketInterface;
13
14
/**
15
 * Class AcceptedFrame
16
 */
17
class AcceptedFrame implements FrameInterface
18
{
19
    /**
20
     * Client address, if available
21
     *
22
     * @var string
23
     */
24
    private $clientAddress;
25
26
    /**
27
     * Connected client socket
28
     *
29
     * @var SocketInterface
30
     */
31
    private $socket;
32
33
    /**
34
     * AcceptResponse constructor.
35
     *
36
     * @param string          $clientAddress Remote client address
37
     * @param SocketInterface $socket Remote socket
38
     */
39 5
    public function __construct($clientAddress, SocketInterface $socket)
40
    {
41 5
        $this->clientAddress = $clientAddress;
42 5
        $this->socket        = $socket;
43 5
    }
44
45
    /** {@inheritdoc} */
46 1
    public function getData()
47
    {
48 1
        return $this->clientAddress;
49
    }
50
51
    /** {@inheritdoc} */
52 5
    public function __toString()
53
    {
54 5
        return $this->clientAddress;
55
    }
56
57
    /**
58
     * Return client socket
59
     *
60
     * @return SocketInterface
61
     */
62 5
    public function getClientSocket()
63
    {
64 5
        return $this->socket;
65
    }
66
67
    /** {@inheritdoc} */
68 7
    public function getRemoteAddress()
69
    {
70 7
        return $this->clientAddress;
71
    }
72
}
73