Passed
Push — refactor/backendModule-ValueOb... ( 355cec )
by Tomas Norre
07:44
created

ModuleMenu   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 56.25%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 10
c 1
b 0
f 0
dl 0
loc 28
ccs 9
cts 16
cp 0.5625
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getCrawlActions() 0 3 1
A fromArray() 0 6 1
1
<?php
2
declare(strict_types=1);
3
4
namespace AOE\Crawler\Value;
5
6
/*
7
 * (c) 2020 AOE GmbH <[email protected]>
8
 *
9
 * This file is part of the TYPO3 Crawler Extension.
10
 *
11
 * It is free software; you can redistribute it and/or modify it under
12
 * the terms of the GNU General Public License, either version 2
13
 * of the License, or any later version.
14
 *
15
 * For the full copyright and license information, please read the
16
 * LICENSE.txt file that was distributed with this source code.
17
 *
18
 * The TYPO3 project - inspiring people to share!
19
 */
20
21
use Assert\Assert;
22
23
final class ModuleMenu
24
{
25
    /** @var CrawlAction[] */
26
    private $crawlActions;
27
28 1
    public function __construct(array $crawlActions)
29
    {
30 1
        Assert::thatAll($crawlActions)
31 1
            ->isInstanceOf(CrawlAction::class);
32
33 1
        $this->crawlActions = $crawlActions;
34 1
    }
35
36 1
    public static function fromArray(array $array): self
37
    {
38 1
        return new self(
39
            array_map(function (string $item): CrawlAction {
40 1
                return new CrawlAction($item, 'label');
41 1
            }, array_keys($array['crawlaction']))
42
        );
43
    }
44
45
    /**
46
     * @return CrawlAction[]
47
     */
48
    public function getCrawlActions(): array
49
    {
50
        return $this->crawlActions;
51
    }
52
}
53