Completed
Push — master ( 9af83e...139fb8 )
by Thomas
21s
created

CustomModule::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 6
ccs 3
cts 3
cp 1
crap 1
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 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\Extension\Model;
15
16
use Drupal\Core\DependencyInjection\ContainerBuilder;
17
18
class CustomModule extends AbstractCustomExtension
19
{
20
    /**
21
     * @var string
22
     */
23
    private $camelCaseMachineName;
24
25
    /**
26
     * {@inheritdoc}
27
     */
28 4
    public function __construct(string $rootPath, string $machineName)
29
    {
30 4
        parent::__construct($rootPath, $machineName);
31
32
        // The same camelize function is used in the Drupal kernel.
33 4
        $this->camelCaseMachineName = ContainerBuilder::camelize($machineName);
34 4
    }
35
36
    /**
37
     * @return string
38
     */
39 1
    public function getCamelCaseMachineName(): string
40
    {
41 1
        return $this->camelCaseMachineName;
42
    }
43
44
    /**
45
     * {@inheritdoc}
46
     */
47 1
    public function serialize(): ?string
48
    {
49 1
        return \serialize(array(
50 1
            $this->rootPath,
51 1
            $this->machineName,
52 1
            $this->camelCaseMachineName,
53
        ));
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 1
    public function unserialize($serialized): void
60
    {
61 1
        list($this->rootPath, $this->machineName, $this->camelCaseMachineName) = \unserialize($serialized);
62 1
    }
63
}
64