Passed
Pull Request — master (#1104)
by Maxim
12:14
created

ContextualObjectNotFoundException   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 6
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 3
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 10
c 1
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Bootloader\Http\Exception;
6
7
use Psr\Container\NotFoundExceptionInterface;
8
use Psr\Http\Message\ServerRequestInterface;
9
use Spiral\Auth\AuthContextInterface;
10
use Spiral\Auth\Middleware\AuthMiddleware;
11
use Spiral\Cookies\Middleware\CookiesMiddleware;
12
use Spiral\Session\Middleware\SessionMiddleware;
13
use Spiral\Session\SessionInterface;
14
15
/**
16
 * The requested object depends on the {@see ServerRequestInterface} context.
17
 * Make sure that the related middleware was added to the pipeline and executed before
18
 * the object is requested from the container.
19
 * For example,
20
 * - {@see CookieQueue} requires {@see CookiesMiddleware}
21
 * - {@see SessionInterface} requires {@see SessionMiddleware}
22
 * - {@see AuthContextInterface} requires {@see AuthMiddleware}
23
 */
24
final class ContextualObjectNotFoundException extends \RuntimeException implements NotFoundExceptionInterface
25
{
26 3
    public function __construct(string $id, ?string $key = null)
27
    {
28 3
        $keyStr = $key !== null ? " by the key `$key`" : '';
29 3
        parent::__construct("`$id` not found in Request attributes{$keyStr}.");
30
    }
31
}
32