Passed
Pull Request — 1.x (#334)
by Akihito
02:32
created

OpenContext::create()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\SemanticLog\Profile\Compact;
6
7
use BEAR\Resource\AbstractRequest;
8
use Koriym\SemanticLogger\AbstractContext;
9
10
use function strtoupper;
11
12
final class OpenContext extends AbstractContext
13
{
14
    /** @psalm-suppress InvalidClassConstantType */
15
    public const TYPE = 'bear_resource_request';
16
17
    /** @psalm-suppress InvalidClassConstantType */
18
    public const SCHEMA_URL = 'https://bearsunday.github.io/BEAR.Resource/schemas/open-context.json';
19
20
    public readonly string $method;
21
    public readonly string $uri;
22
23
    public function __construct(AbstractRequest $request)
24
    {
25
        $this->method = strtoupper($request->method);
0 ignored issues
show
Bug introduced by
The property method is declared read-only in BEAR\Resource\SemanticLo...ile\Compact\OpenContext.
Loading history...
26
        $this->uri = $request->toUri();
0 ignored issues
show
Bug introduced by
The property uri is declared read-only in BEAR\Resource\SemanticLo...ile\Compact\OpenContext.
Loading history...
27
    }
28
29
    public static function create(AbstractRequest $request): self
30
    {
31
        return new self($request);
32
    }
33
}
34