Completed
Pull Request — develop (#22)
by Barney
01:41
created

TimersException::stop()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 6
rs 9.4285
1
<?php
2
/**
3
 * @codingStandardsIgnoreStart
4
 *
5
 * @author       Barney Hanlon <[email protected]>
6
 * @copyright    Barney Hanlon 2017
7
 * @license      https://opensource.org/licenses/MIT
8
 *
9
 * @codingStandardsIgnoreEnd
10
 */
11
12
namespace Shrikeh\GuzzleMiddleware\TimerLogger\ResponseTimeLogger\Exception;
13
14
use Exception;
15
use RuntimeException;
16
17
/**
18
 * Class TimersException.
19
 */
20
final class TimersException extends RuntimeException
21
{
22
    const TIMER_START_MSG = 'An error occurred while attempting to start the timer';
23
    const TIMER_START_CODE = 32;
24
25
    const TIMER_STOP_MSG = 'An error occurred while attempting to stop the timer';
26
    const TIMER_STOP_CODE = 64;
27
28
    /**
29
     * @param \Exception $e The timer exception
30
     *
31
     * @return TimersException
32
     */
33
    public static function start(Exception $e)
34
    {
35
        return new self(
36
            self::TIMER_STOP_MSG,
37
            self::TIMER_STOP_CODE,
38
            $e
39
        );
40
    }
41
42
    /**
43
     * @param \Exception $e The timer exception
44
     *
45
     * @return TimersException
46
     */
47
    public static function stop(Exception $e)
48
    {
49
        return new self(
50
            self::TIMER_STOP_MSG,
51
            self::TIMER_STOP_CODE,
52
            $e
53
        );
54
    }
55
}
56