Passed
Push — master ( 6c7aff...ce6d49 )
by
unknown
46:49 queued 20:16
created

AbstractProvider   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 11
dl 0
loc 29
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getLabel() 0 3 1
A getIdentifier() 0 3 1
A getLanguageService() 0 3 1
A __invoke() 0 9 2
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\Lowlevel\ConfigurationModuleProvider;
19
20
use TYPO3\CMS\Core\Localization\LanguageService;
21
22
/**
23
 * Can be used by specific provider implementations and supports
24
 * basic functionality, required by the interface.
25
 */
26
abstract class AbstractProvider implements ProviderInterface
27
{
28
    protected string $identifier;
29
    protected string $label;
30
31
    public function __invoke(array $attributes): self
32
    {
33
        if (!($attributes['label'] ?? false)) {
34
            throw new \RuntimeException('Attribute \'label\' must be set to use ' . __CLASS__, 1606478090);
35
        }
36
37
        $this->identifier = $attributes['identifier'];
38
        $this->label = $attributes['label'];
39
        return $this;
40
    }
41
42
    public function getIdentifier(): string
43
    {
44
        return $this->identifier;
45
    }
46
47
    public function getLabel(): string
48
    {
49
        return $this->getLanguageService()->sL($this->label);
50
    }
51
52
    protected function getLanguageService(): LanguageService
53
    {
54
        return $GLOBALS['LANG'];
55
    }
56
}
57