fromAttributeNameAndRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 2
dl 0
loc 8
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace PSR7Csrf\Exception;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
use UnexpectedValueException;
9
10
class SessionAttributeNotFoundException extends UnexpectedValueException implements ExceptionInterface
11
{
12 1
    public static function fromAttributeNameAndRequest(string $attributeName, ServerRequestInterface $request) : self
13
    {
14 1
        return new self(sprintf(
15 1
            'Provided request contains no matching session attribute "%s", attributes %s exist',
16
            $attributeName,
17 1
            json_encode(array_keys($request->getAttributes()))
18
        ));
19
    }
20
}
21