DonutRequest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 9 1
A __construct() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\QueryRepository;
6
7
use BEAR\Resource\AbstractRequest;
8
use Override;
9
use Stringable;
10
11
use function sprintf;
12
13
final class DonutRequest implements Stringable
14
{
15
    public function __construct(
16
        private readonly AbstractRequest $request,
17
        private readonly DonutRendererInterface $donutStorage,
18
        private readonly SurrogateKeys $etags,
19
    ) {
20
    }
21
22
    #[Override]
23
    public function __toString(): string
24
    {
25
        $view = (string) ($this->request)();
26
        $uri =  (string) $this->request->resourceObject->uri;
27
        $this->etags->addTag($this->request->resourceObject);
28
        $this->donutStorage->setView($uri, $view);
29
30
        return sprintf(ResourceDonut::FOMRAT, $uri);
31
    }
32
}
33