Request::setRequest()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 1
c 2
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Enjoys\Forms\Traits;
6
7
use HttpSoft\ServerRequest\ServerRequestCreator;
8
use Psr\Http\Message\ServerRequestInterface;
9
10
trait Request
11
{
12
    /**
13
     * @psalm-suppress PropertyNotSetInConstructor
14
     */
15
    private ServerRequestInterface $request;
16
17 314
    public function setRequest(?ServerRequestInterface $request = null): void
18
    {
19 314
        $this->request = $request ?? ServerRequestCreator::createFromGlobals();
20
    }
21
22 165
    public function getRequest(): ServerRequestInterface
23
    {
24 165
        return $this->request;
25
    }
26
}
27