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

CurrentRequest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 3 1
A get() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\Http;
6
7
use Psr\Http\Message\ServerRequestInterface;
8
use Spiral\Core\Attribute\Scope;
9
use Spiral\Http\Exception\HttpException;
10
11
/**
12
 * Provides access to the current request in the `http` scope.
13
 * @internal
14
 */
15
#[Scope('http')]
16
final class CurrentRequest
17
{
18
    private ?ServerRequestInterface $request = null;
19
20 130
    public function set(ServerRequestInterface $request): void
21
    {
22 130
        $this->request = $request;
23
    }
24
25 132
    public function get(): ?ServerRequestInterface
26
    {
27 132
        return $this->request;
28
    }
29
}
30