AbstractIo   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 90%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 41
ccs 9
cts 10
cp 0.9
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getLastPhpErrorMessage() 0 11 2
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\Socket\Io;
11
12
use AsyncSockets\Socket\SocketInterface;
13
14
/**
15
 * Class AbstractIo
16
 */
17
abstract class AbstractIo implements IoInterface
18
{
19
    /**
20
     * Amount of attempts to set data
21
     */
22
    const IO_ATTEMPTS = 10;
23
24
    /**
25
     * Socket
26
     *
27
     * @var SocketInterface
28
     */
29
    protected $socket;
30
31
    /**
32
     * AbstractIo constructor.
33
     *
34
     * @param SocketInterface $socket Socket object
35
     */
36 232
    public function __construct(SocketInterface $socket)
37
    {
38 232
        $this->socket = $socket;
39 232
    }
40
41
    /**
42
     * Return last php error message as string
43
     *
44
     * @return string
45
     */
46 4
    protected function getLastPhpErrorMessage()
47
    {
48 4
        $lastError = error_get_last();
49 4
        if (!empty($lastError)) {
50 4
            $phpMessage = explode(':', $lastError['message'], 2);
51 4
            $phpMessage = trim(trim(end($phpMessage)), '.') . '.';
52 4
            return $phpMessage;
53
        }
54
55
        return '';
56
    }
57
}
58