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

OpenContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 20
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 3 1
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