Completed
Push — master ( 298e09...565401 )
by Ivannis Suárez
02:36
created

TimeoutException::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 5
nc 2
nop 2
1
<?php
2
3
/*
4
 * This file is part of the Cubiche package.
5
 *
6
 * Copyright (c) Cubiche
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 Cubiche\Core\Async\Promise;
13
14
/**
15
 * Timeout Exception class.
16
 *
17
 * @author Karel Osorio Ramírez <[email protected]>
18
 */
19
class TimeoutException extends CancellationException
20
{
21
    /**
22
     * @var int|float
23
     */
24
    protected $time;
25
26
    /**
27
     * @param int|float $time
28
     * @param string    $message
29
     */
30
    public function __construct($time, $message = null)
31
    {
32
        $this->time = $time;
33
        if ($message !== null) {
34
            $message = \sprintf('The promise has been cancelled, timeout expired after %f seconds', $this->time);
35
        }
36
37
        parent::__construct($message);
38
    }
39
}
40