Completed
Push — master ( e22f7e...4537c6 )
by Evgenij
06:03
created

TransferException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 4
cts 4
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 5
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
11
namespace AsyncSockets\Exception;
12
13
use AsyncSockets\Socket\SocketInterface;
14
15
/**
16
 * Class TransferException.
17
 * This class of exceptions describes failures with network transfers.
18
 */
19
class TransferException extends NetworkSocketException
20
{
21
    /**
22
     * Exception with incoming data
23
     */
24
    const DIRECTION_RECV = 0;
25
26
    /**
27
     * Exception with outgoing data
28
     */
29
    const DIRECTION_SEND = 1;
30
31
    /**
32
     * Transfer direction
33
     *
34
     * @var int
35
     */
36
    private $direction;
37
38
    /**
39
     * @inheritDoc
40
     */
41 11
    public function __construct(
42
        SocketInterface $socket,
43
        $direction,
44
        $message = '',
45
        $code = 0,
46
        \Exception $previous = null
47
    ) {
48 11
        parent::__construct($socket, $message, $code, $previous);
49 11
        $this->direction = $direction;
50 11
    }
51
52
    /**
53
     * Return direction of this exception
54
     *
55
     * @return int
56
     */
57
    public function getDirection()
58
    {
59
        return $this->direction;
60
    }
61
}
62