Completed
Pull Request — master (#6)
by Billie
09:20
created

ActionFailed::fromPrevious()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of CaptainHook.
4
 *
5
 * (c) Sebastian Feldmann <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
namespace SebastianFeldmann\CaptainHook\Exception;
11
12
/**
13
 * Class ActionFailed
14
 *
15
 * @package CaptainHook
16
 * @author  Sebastian Feldmann <[email protected]>
17
 * @link    https://github.com/sebastianfeldmann/captainhook
18
 * @since   Class available since Release 0.9.0
19
 */
20
class ActionFailed extends \Exception
21
{
22
    /**
23
     * Return a Action Failed exception.
24
     *
25
     * @param string $msg
26
     * @return \SebastianFeldmann\CaptainHook\Exception\ActionFailed
27
     */
28 13
    public static function withMessage($msg)
29
    {
30 13
        return new self($msg);
31
    }
32
33
    /**
34
     * Create a new exception based on a previous exception.
35
     *
36
     * This is useful if you need to rethrow an exception of any reason.
37
     *
38
     * @param \SebastianFeldmann\CaptainHook\Exception\ActionFailed $exception
39
     *
40
     * @return \SebastianFeldmann\CaptainHook\Exception\ActionFailed
41
     */
42
    public static function fromPrevious(ActionFailed $exception)
43
    {
44
        return new self($exception->getMessage(), $exception->getCode(), $exception);
45
    }
46
}
47