Passed
Push — typo3_11 ( 1a41a1...78d6ec )
by Torben
07:24
created

ForeignRecordDemand::createFromSettings()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 9
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the Extension "sf_event_mgt" for TYPO3 CMS.
7
 *
8
 * For the full copyright and license information, please read the
9
 * LICENSE.txt file that was distributed with this source code.
10
 */
11
12
namespace DERHANSEN\SfEventMgt\Domain\Model\Dto;
13
14
/**
15
 * ForeignRecord demand
16
 */
17
class ForeignRecordDemand
18
{
19
    protected string $storagePage = '';
20
    protected bool $restrictForeignRecordsToStoragePage = false;
21
22
    public function getStoragePage(): string
23
    {
24
        return $this->storagePage;
25
    }
26
27
    public function setStoragePage(string $storagePage): void
28
    {
29
        $this->storagePage = $storagePage;
30
    }
31
32
    public function getRestrictForeignRecordsToStoragePage(): bool
33
    {
34
        return $this->restrictForeignRecordsToStoragePage;
35
    }
36
37
    public function setRestrictForeignRecordsToStoragePage(bool $restrictForeignRecordsToStoragePage): void
38
    {
39
        $this->restrictForeignRecordsToStoragePage = $restrictForeignRecordsToStoragePage;
40
    }
41
42
    /**
43
     * Creates a new ForeignRecordDemand object from the given settings.
44
     *
45
     * @param array $settings
46
     * @return ForeignRecordDemand
47
     */
48
    public static function createFromSettings(array $settings = []): self
49
    {
50
        $demand = new ForeignRecordDemand();
51
        $demand->setStoragePage((string)($settings['storagePage'] ?? ''));
52
        $demand->setRestrictForeignRecordsToStoragePage(
53
            (bool)($settings['restrictForeignRecordsToStoragePage'] ?? false)
54
        );
55
56
        return $demand;
57
    }
58
}
59