MessageActionHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
dl 0
loc 39
rs 10
c 0
b 0
f 0
wmc 3
lcom 1
cbo 2

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getEventDispatcher() 0 4 1
A write() 0 5 1
1
<?php
2
3
/*
4
 * This file is part of the slince/spike package.
5
 *
6
 * (c) Slince <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Spike\Client\Handler;
13
14
use React\Socket\ConnectionInterface;
15
use Slince\EventDispatcher\DispatcherInterface;
16
use Spike\Client\Client;
17
18
abstract class MessageActionHandler implements ActionHandlerInterface
19
{
20
    /**
21
     * @var Client
22
     */
23
    protected $client;
24
25
    /**
26
     * @var ConnectionInterface
27
     */
28
    protected $connection;
29
30
    public function __construct(Client $client, ConnectionInterface $connection)
31
    {
32
        $this->client = $client;
33
        $this->connection = $connection;
34
    }
35
36
    /**
37
     * Gets the event dispatcher.
38
     *
39
     * @return DispatcherInterface
40
     */
41
    public function getEventDispatcher()
42
    {
43
        return $this->client->getEventDispatcher();
44
    }
45
46
    /**
47
     * Write data to connection.
48
     *
49
     * @param string $data
50
     */
51
    public function write($data)
52
    {
53
        $this->connection->write($data);
54
        $this->client->setActiveAt(new \DateTime('now'));
55
    }
56
}