Completed
Branch 0.4-dev (999b58)
by Evgenij
18:41
created

NetworkSocketException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 1
dl 33
loc 33
ccs 6
cts 6
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getSocket() 4 4 1
A __construct() 5 5 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-2016, 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 NetworkSocketException.
17
 * This exception can be thrown during network operations.
18
 */
19 View Code Duplication
class NetworkSocketException extends SocketException
20
{
21
    /**
22
     * Socket with this exception
23
     *
24
     * @var SocketInterface
25
     */
26
    private $socket;
27
28
    /**
29
     * Construct the exception.
30
     *
31
     * @param SocketInterface $socket   Socket object
32
     * @param string          $message  The Exception message to throw.
33
     * @param int             $code     The Exception code.
34
     * @param \Exception      $previous The previous exception used for the exception chaining.
35
     */
36 115
    public function __construct(SocketInterface $socket, $message = '', $code = 0, \Exception $previous = null)
37
    {
38 115
        parent::__construct($message, $code, $previous);
39 115
        $this->socket = $socket;
40 115
    }
41
42
    /**
43
     * Return socket with this exception
44
     *
45
     * @return SocketInterface
46
     */
47 14
    public function getSocket()
48
    {
49 14
        return $this->socket;
50
    }
51
}
52