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

RequestNotFoundException::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 5
c 1
b 0
f 0
nc 1
nop 2
dl 0
loc 10
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\RequestTimers\Exception;
13
14
use Exception;
15
use Psr\Http\Message\RequestInterface;
16
use RuntimeException;
17
18
/**
19
 * Class RequestNotFoundException.
20
 */
21
final class RequestNotFoundException extends RuntimeException
22
{
23
    const MSG = 'A Request object for a request to %s could not be found';
24
    const CODE = 16;
25
26
    /**
27
     * @var RequestInterface
28
     */
29
    private $request;
30
31
    /**
32
     * RequestNotFoundException constructor.
33
     *
34
     * @param RequestInterface $request The Request we can't find a timer for
35
     * @param \Exception       $e       A previous exception, if any
36
     */
37
    public function __construct(
38
        RequestInterface $request,
39
        Exception $e = null
40
    ) {
41
        $this->request = $request;
42
43
        parent::__construct(
44
            sprintf(self::MSG, $request->getUri()),
45
            self::CODE,
46
            $e
47
        );
48
    }
49
50
    /**
51
     * @return \Psr\Http\Message\RequestInterface
52
     */
53
    public function getRequest()
54
    {
55
        return $this->request;
56
    }
57
}
58