CharsetConfigurationTrait::getConfiguredCharset()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the ekino Drupal Debug project.
7
 *
8
 * (c) ekino
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Ekino\Drupal\Debug\Configuration;
15
16
use Ekino\Drupal\Debug\Configuration\Model\ActionConfiguration;
17
use Ekino\Drupal\Debug\Configuration\Model\DefaultsConfiguration as DefaultsConfigurationModel;
18
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
19
20
trait CharsetConfigurationTrait
21
{
22 19
    private static function addCharsetConfigurationNode(NodeBuilder $nodeBuilder, ?string $defaultCharset): NodeBuilder
23
    {
24
        return $nodeBuilder
0 ignored issues
show
Bug Best Practice introduced by
The expression return $nodeBuilder->sca...$defaultCharset)->end() returns the type null which is incompatible with the type-hinted return Symfony\Component\Config...ion\Builder\NodeBuilder.
Loading history...
25 19
            ->scalarNode('charset')
26 19
                ->defaultValue($defaultCharset)
27 19
            ->end();
28
    }
29
30 19
    private static function addCharsetConfigurationNodeFromDefaultsConfiguration(NodeBuilder $nodeBuilder, DefaultsConfigurationModel $defaultsConfiguration): NodeBuilder
31
    {
32 19
        return self::addCharsetConfigurationNode($nodeBuilder, $defaultsConfiguration->getCharset());
33
    }
34
35 2
    private static function getConfiguredCharset(ActionConfiguration $actionConfiguration): ?string
36
    {
37 2
        $processedConfiguration = $actionConfiguration->getProcessedConfiguration();
38
39 2
        return $processedConfiguration['charset'];
40
    }
41
}
42