Passed
Push — trunk ( ff5efa...610829 )
by Christian
14:10 queued 22s
created

getExpectedClass()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Shopware\Storefront\Theme\StorefrontPluginConfiguration;
4
5
use Shopware\Core\Framework\Struct\Collection;
6
7
/**
8
 * @extends Collection<StorefrontPluginConfiguration>
9
 */
10
class StorefrontPluginConfigurationCollection extends Collection
11
{
12
    public function __construct(iterable $elements = [])
13
    {
14
        parent::__construct([]);
15
16
        foreach ($elements as $element) {
17
            $this->validateType($element);
18
19
            $this->set($element->getTechnicalName(), $element);
20
        }
21
    }
22
23
    public function add($element): void
24
    {
25
        $this->validateType($element);
26
27
        $this->set($element->getTechnicalName(), $element);
28
    }
29
30
    public function getByTechnicalName(string $name): ?StorefrontPluginConfiguration
31
    {
32
        return $this->filter(function (StorefrontPluginConfiguration $config) use ($name) {
33
            return $config->getTechnicalName() === $name;
34
        })->first();
35
    }
36
37
    public function getThemes(): StorefrontPluginConfigurationCollection
38
    {
39
        return $this->filter(function (StorefrontPluginConfiguration $configuration) {
40
            return $configuration->getIsTheme();
41
        });
42
    }
43
44
    public function getNoneThemes(): StorefrontPluginConfigurationCollection
45
    {
46
        return $this->filter(function (StorefrontPluginConfiguration $configuration) {
47
            return !$configuration->getIsTheme();
48
        });
49
    }
50
51
    protected function getExpectedClass(): ?string
52
    {
53
        return StorefrontPluginConfiguration::class;
54
    }
55
}
56