Passed
Branch master (c87ba8)
by Christian
16:02
created

DashboardPreset   A

Complexity

Total Complexity 11

Size/Duplication

Total Lines 101
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 20
dl 0
loc 101
rs 10
c 0
b 0
f 0
wmc 11

8 Methods

Rating   Name   Duplication   Size   Complexity  
A getDescription() 0 3 2
A getIconIdentifier() 0 3 1
A __construct() 0 14 2
A getTitle() 0 3 2
A getIdentifier() 0 3 1
A getLanguageService() 0 3 1
A isShowInWizard() 0 3 1
A getDefaultWidgets() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the TYPO3 CMS project.
7
 *
8
 * It is free software; you can redistribute it and/or modify it under
9
 * the terms of the GNU General Public License, either version 2
10
 * of the License, or any later version.
11
 *
12
 * For the full copyright and license information, please read the
13
 * LICENSE.txt file that was distributed with this source code.
14
 *
15
 * The TYPO3 project - inspiring people to share!
16
 */
17
18
namespace TYPO3\CMS\Dashboard;
19
20
use TYPO3\CMS\Core\Localization\LanguageService;
21
22
/**
23
 * @internal
24
 */
25
class DashboardPreset
26
{
27
    /**
28
     * @var string
29
     */
30
    protected $identifier;
31
32
    /**
33
     * @var string
34
     */
35
    protected $title;
36
37
    /**
38
     * @var string
39
     */
40
    protected $iconIdentifier;
41
42
    /**
43
     * @var string
44
     */
45
    protected $description = '';
46
47
    /**
48
     * @var string[]
49
     */
50
    protected $defaultWidgets = [];
51
52
    /**
53
     * @var bool
54
     */
55
    protected $showInWizard = true;
56
57
    public function __construct(
58
        string $identifier,
59
        string $title,
60
        string $description,
61
        string $iconIdentifier = 'content-dashboard',
62
        array $defaultWidgets = [],
63
        bool $showInWizard = true
64
    ) {
65
        $this->identifier = $identifier;
66
        $this->title = $title;
67
        $this->description = $description;
68
        $this->iconIdentifier = $iconIdentifier ?: 'content-dashboard';
69
        $this->defaultWidgets = $defaultWidgets;
70
        $this->showInWizard = $showInWizard;
71
    }
72
73
    /**
74
     * @return string
75
     */
76
    public function getIdentifier(): string
77
    {
78
        return $this->identifier;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getIconIdentifier(): string
85
    {
86
        return $this->iconIdentifier;
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getTitle(): string
93
    {
94
        return $this->getLanguageService()->sl($this->title) ?: $this->title;
95
    }
96
    /**
97
     * @return string
98
     */
99
    public function getDescription(): string
100
    {
101
        return $this->getLanguageService()->sl($this->description) ?: $this->description;
102
    }
103
104
    /**
105
     * @return string[]
106
     */
107
    public function getDefaultWidgets(): array
108
    {
109
        return $this->defaultWidgets;
110
    }
111
112
    /**
113
     * @return bool
114
     */
115
    public function isShowInWizard(): bool
116
    {
117
        return $this->showInWizard;
118
    }
119
120
    /**
121
     * @return LanguageService
122
     */
123
    protected function getLanguageService(): LanguageService
124
    {
125
        return $GLOBALS['LANG'];
126
    }
127
}
128