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

UnmanagedSocketException::zombieSocketDetected()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 8
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 12
ccs 8
cts 8
cp 1
rs 9.4285
cc 1
eloc 8
nc 1
nop 1
crap 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\Exception;
11
12
use AsyncSockets\Socket\SocketInterface;
13
14
/**
15
 * Class UnmanagedSocketException. Throws when system detects some unexpected conditions and suppose
16
 * that operation couldn't be completed
17
 */
18
class UnmanagedSocketException extends NetworkSocketException
19
{
20
    /**
21
     * Socket data will not be correctly processed by application.
22
     *
23
     * @param SocketInterface $socket Socket object caused exception
24
     *
25
     * @return UnmanagedSocketException
26
     */
27 2
    public static function zombieSocketDetected(SocketInterface $socket)
28
    {
29 2
        return new self(
30 2
            $socket,
31 2
            sprintf(
32
                'System has detected a zombie connection %s and closed it. '.
33 2
                'If you see this message it means that application ' .
34 2
                'has lost control on one of its sockets.',
35
                (string) $socket
36 2
            )
37 2
        );
38
    }
39
}
40