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

ForeignRecordDemand   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 12
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setRestrictForeignRecordsToStoragePage() 0 3 1
A getStoragePage() 0 3 1
A createFromSettings() 0 9 1
A setStoragePage() 0 3 1
A getRestrictForeignRecordsToStoragePage() 0 3 1
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