Passed
Push — master ( bdc105...ec8122 )
by Peter
01:57
created

Assets::createFromArray()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 8
Ratio 100 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 8
loc 8
ccs 5
cts 5
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 5
nc 2
nop 1
crap 2
1
<?php
2
3
namespace PtrTn\Battlerite\Dto\Matches;
4
5
use Webmozart\Assert\Assert;
6
7 View Code Duplication
class Assets
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...
8
{
9
    /**
10
     * @var Asset[]
11
     */
12
    public $assets;
13
14 3
    private function __construct(array $assets)
15
    {
16 3
        Assert::allIsInstanceOf($assets, Asset::class);
17
18 3
        $this->assets = $assets;
19 3
    }
20
21 3
    public static function createFromArray(array $assets): self
22
    {
23 3
        $createdAssets = [];
24 3
        foreach ($assets as $asset) {
25 3
            $createdAssets[] = Asset::createFromArray($asset);
26
        }
27 3
        return new self($createdAssets);
28
    }
29
}
30