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

SendDataException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 26
loc 26
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A failedToSendData() 4 4 1
A __construct() 8 8 1

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
 * 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\Exception;
11
12
use AsyncSockets\Socket\SocketInterface;
13
14
/**
15
 * Class SendDataException. Thrown any time there is a problem with sending data to remote side
16
 */
17 View Code Duplication
class SendDataException extends TransferException
18
{
19
    /**
20
     * Creates data sending failure
21
     *
22
     * @param SocketInterface $socket Socket with error
23
     *
24
     * @return SendDataException
25
     */
26 6
    public static function failedToSendData(SocketInterface $socket)
27
    {
28 6
        return new self($socket, 'Failed to send data.');
29
    }
30
31
    /**
32
     * @inheritDoc
33
     */
34 9
    public function __construct(
35
        SocketInterface $socket,
36
        $message = '',
37
        $code = 0,
38
        \Exception $previous = null
39
    ) {
40 9
        parent::__construct($socket, self::DIRECTION_SEND, $message, $code, $previous);
41 9
    }
42
}
43