Passed
Push — refactor/backendModule-ValueOb... ( 9011ea...037899 )
by Tomas Norre
13:04
created

ModuleSettings::getLogDisplay()   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
3
declare(strict_types=1);
4
5
namespace AOE\Crawler\Value;
6
7
/*
8
 * (c) 2020 AOE GmbH <[email protected]>
9
 *
10
 * This file is part of the TYPO3 Crawler Extension.
11
 *
12
 * It is free software; you can redistribute it and/or modify it under
13
 * the terms of the GNU General Public License, either version 2
14
 * of the License, or any later version.
15
 *
16
 * For the full copyright and license information, please read the
17
 * LICENSE.txt file that was distributed with this source code.
18
 *
19
 * The TYPO3 project - inspiring people to share!
20
 */
21
22
final class ModuleSettings
23
{
24
    /**
25
     * @var string
26
     */
27
    private $crawlAction;
28
29
    /**
30
     * @var int
31
     */
32
    private $pages;
33
34
    /**
35
     * @var int
36
     */
37
    private $depth;
38
39
    /**
40
     * @var int
41
     */
42
    private $itemsPerPage;
43
44
    /**
45
     * @var string
46
     */
47
    private $logDisplay;
48
49
    public function __construct(
50
        string $crawlAction = 'start',
51
        int $pages = 0,
52
        int $depth = 0,
53
        int $itemsPerPage = 5,
54
        string $logDisplay = 'all'
55
    ) {
56
        $this->crawlAction = $crawlAction;
57
        $this->pages = $pages;
58
        $this->depth = $depth;
59
        $this->itemsPerPage = $itemsPerPage;
60
        $this->logDisplay = $logDisplay;
61
    }
62
63
    public static function fromArray(array $array): self
64
    {
65
        return new self(
66
            (string) $array['crawlaction'],
67
            (int) $array['pages'],
68
            (int) $array['depth'],
69
            (int) $array['itemPerPage'],
70
            (string) $array['log_display']
71
        );
72
    }
73
74
    /**
75
     * @return string
76
     */
77
    public function getCrawlAction(): string
78
    {
79
        return $this->crawlAction;
80
    }
81
82
    /**
83
     * @return int
84
     */
85
    public function getPages(): int
86
    {
87
        return $this->pages;
88
    }
89
90
    /**
91
     * @return int
92
     */
93
    public function getDepth(): int
94
    {
95
        return $this->depth;
96
    }
97
98
    /**
99
     * @return int
100
     */
101
    public function getItemsPerPage(): int
102
    {
103
        return $this->itemsPerPage;
104
    }
105
106
    /**
107
     * @return string
108
     */
109
    public function getLogDisplay(): string
110
    {
111
        return $this->logDisplay;
112
    }
113
}
114