Examples::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 3
CRAP Score 2

Importance

Changes 0
Metric Value
dl 6
loc 6
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Aweapi\Openapi\Objects;
6
7
use Aweapi\Openapi\Map;
8
9 View Code Duplication
final class Examples extends Map
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
    private $items = [];
12
13 12
    public function __construct(iterable $examples)
14
    {
15 12
        foreach ($examples as $name => $example) {
16 12
            $this->setItem($name, $example);
17
        }
18
    }
19
20
    /**
21
     * @return array<string, ExampleAggregate>
0 ignored issues
show
Documentation introduced by
The doc-type array<string, could not be parsed: Expected ">" at position 5, but found "end of type". (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
22
     */
23 10
    public function getItems(): array
24
    {
25 10
        return $this->items;
26
    }
27
28 10
    private function setItem(string $name, ExampleAggregate $example): void
29
    {
30 10
        $this->items[$name] = $example;
31
    }
32
}
33