CallbackRequestBuilder::getItems()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Builders;
6
7
use Aweapi\Openapi\Objects;
8
9 View Code Duplication
final class CallbackRequestBuilder implements Objects\CallbackRequestFactory
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
{
11
    use Properties\OptionalExtensions;
12
13
    private $items = [];
14
15 3
    public function addItems(iterable $items): self
16
    {
17 3
        foreach ($items as $expression => $path) {
18 3
            $this->setItem($expression, $path);
19
        }
20
21 3
        return $this;
22
    }
23
24 4
    public function createCallbackRequest(): Objects\CallbackRequest
25
    {
26 4
        return new Objects\CallbackRequest(
27 4
            array_map(
28
                static function (Objects\PathFactory $factory): Objects\Path {
29 3
                    return $factory->createPath();
30 4
                },
31 4
                $this->getItems()
32
            ),
33 4
            $this->getExtensions()
34
        );
35
    }
36
37 3
    public function setItem(string $expression, Objects\PathFactory $path): self
38
    {
39 3
        $this->items[$expression] = $path;
40
41 3
        return $this;
42
    }
43
44 4
    private function getItems(): array
45
    {
46 4
        return $this->items;
47
    }
48
}
49