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

SocketExceptionEvent   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getException() 0 4 1
A __construct() 0 9 1
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\Event;
12
13
use AsyncSockets\Exception\SocketException;
14
use AsyncSockets\RequestExecutor\RequestExecutorInterface;
15
use AsyncSockets\Socket\SocketInterface;
16
17
/**
18
 * Class SocketExceptionEvent
19
 *
20
 * @api
21
 */
22
class SocketExceptionEvent extends Event
23
{
24
    /**
25
     * Exception linked with event
26
     *
27
     * @var SocketException
28
     */
29
    private $exception;
30
31
    /**
32
     * Constructor
33
     *
34
     * @param SocketException          $exception Exception occurred during request
35
     * @param RequestExecutorInterface $executor Request executor object
36
     * @param SocketInterface          $socket   Socket for this request
37
     * @param mixed                    $context  Any optional user data for event
38
     */
39 52
    public function __construct(
40
        SocketException          $exception,
41
        RequestExecutorInterface $executor,
42
        SocketInterface          $socket,
43
        $context
44
    ) {
45 52
        parent::__construct($executor, $socket, $context, EventType::EXCEPTION);
46 52
        $this->exception = $exception;
47 52
    }
48
49
    /**
50
     * Return thrown exception
51
     *
52
     * @return SocketException
53
     */
54 13
    public function getException()
55
    {
56 13
        return $this->exception;
57
    }
58
}
59