Completed
Branch master (1d1574)
by Evgenij
18:38
created

DataAlertEvent   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getTotalAttempts() 0 4 1
A getAttempt() 0 4 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
namespace AsyncSockets\Event;
11
12
use AsyncSockets\RequestExecutor\RequestExecutorInterface;
13
use AsyncSockets\Socket\SocketInterface;
14
15
/**
16
 * Class DataAlertEvent
17
 */
18
class DataAlertEvent extends IoEvent
19
{
20
    /**
21
     * Total amount of attempts before closing connection
22
     *
23
     * @var int
24
     */
25
    private $totalAttempts;
26
27
    /**
28
     * Current attempt number, the first is 1
29
     *
30
     * @var int
31
     */
32
    private $attempt;
33
34
    /**
35
     * DataAlertEvent constructor
36
     *
37
     * @param RequestExecutorInterface $executor Request executor object
38
     * @param SocketInterface          $socket Socket for this request
39
     * @param mixed                    $context Any optional user data for event
40
     * @param int                      $attempt Current attempt from 1
41
     * @param int                      $totalAttempts Total amount of attempts
42
     */
43 7
    public function __construct(
44
        RequestExecutorInterface $executor,
45
        SocketInterface $socket,
46
        $context,
47
        $attempt,
48
        $totalAttempts
49
    ) {
50 7
        parent::__construct($executor, $socket, $context, EventType::DATA_ALERT);
51 7
        $this->totalAttempts = $totalAttempts;
52 7
        $this->attempt = $attempt;
53 7
    }
54
55
    /**
56
     * Return TotalAttempts
57
     *
58
     * @return int
59
     */
60 1
    public function getTotalAttempts()
61
    {
62 1
        return $this->totalAttempts;
63
    }
64
65
    /**
66
     * Return Attempt
67
     *
68
     * @return int
69
     */
70 1
    public function getAttempt()
71
    {
72 1
        return $this->attempt;
73
    }
74
}
75