Completed
Push — develop ( cc8c81...372a4c )
by Barney
14s
created

TimersException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 100 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 33
loc 33
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A start() 6 6 1
A stop() 6 6 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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 View Code Duplication
final class TimersException extends RuntimeException
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
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