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

ModuleMenu::getCrawlActions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 3
cp 0
crap 2
rs 10
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