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

CompleteContext   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 38
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 38
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A create() 0 3 1
A __construct() 0 15 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Resource\SemanticLog\Profile\Compact;
6
7
use BEAR\Resource\ResourceObject;
8
use BEAR\Resource\Types;
9
use Koriym\SemanticLogger\AbstractContext;
10
11
/**
12
 * @psalm-import-type Headers from Types
13
 * @psalm-import-type HttpBody from Types
14
 */
15
final class CompleteContext extends AbstractContext
16
{
17
    /** @psalm-suppress InvalidClassConstantType */
18
    public const TYPE = 'bear_resource_complete';
19
20
    /** @psalm-suppress InvalidClassConstantType */
21
    public const SCHEMA_URL = 'https://bearsunday.github.io/BEAR.Resource/schemas/complete-context.json';
22
23
    public readonly string $uri;
24
    public readonly int $code;
25
26
    /** @var Headers */
0 ignored issues
show
Bug introduced by
The type BEAR\Resource\SemanticLog\Profile\Compact\Headers was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
    public readonly array $headers;
28
29
    /** @var HttpBody  */
0 ignored issues
show
Bug introduced by
The type BEAR\Resource\SemanticLog\Profile\Compact\HttpBody was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
30
    public readonly mixed $body;
31
    public readonly string $view;
32
33
    public function __construct(ResourceObject $resource, OpenContext $openContext)
34
    {
35
        // Trigger rendering to get view
36
        $resourceString = (string) $resource;
37
        unset($resourceString);
38
39
        $this->uri = (string) $resource->uri;
0 ignored issues
show
Bug introduced by
The property uri is declared read-only in BEAR\Resource\SemanticLo...Compact\CompleteContext.
Loading history...
40
        $this->code = $resource->code;
0 ignored issues
show
Bug introduced by
The property code is declared read-only in BEAR\Resource\SemanticLo...Compact\CompleteContext.
Loading history...
41
        $this->headers = $resource->headers;
0 ignored issues
show
Bug introduced by
The property headers is declared read-only in BEAR\Resource\SemanticLo...Compact\CompleteContext.
Loading history...
42
        /** @psalm-suppress MixedAssignment */
43
        /** @phpstan-ignore-next-line */
44
        $this->body = $resource->body;
0 ignored issues
show
Bug introduced by
The property body is declared read-only in BEAR\Resource\SemanticLo...Compact\CompleteContext.
Loading history...
45
        /** @psalm-suppress PossiblyNullPropertyAssignmentValue */
46
        $this->view = $resource->view ?? '';
0 ignored issues
show
Bug introduced by
The property view is declared read-only in BEAR\Resource\SemanticLo...Compact\CompleteContext.
Loading history...
47
        unset($openContext);
48
    }
49
50
    public static function create(ResourceObject $resource, OpenContext $openContext): self
51
    {
52
        return new self($resource, $openContext);
53
    }
54
}
55