CustomModule::serialize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 0
dl 0
loc 6
ccs 5
cts 5
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 9
    public function __construct(string $rootPath, string $machineName)
29
    {
30 9
        parent::__construct($rootPath, $machineName);
31
32
        // The same camelize function is used in the Drupal kernel.
33 9
        $this->camelCaseMachineName = ContainerBuilder::camelize($machineName);
34 9
    }
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 3
    public function serialize(): ?string
48
    {
49 3
        return \serialize(array(
50 3
            $this->rootPath,
51 3
            $this->machineName,
52 3
            $this->camelCaseMachineName,
53
        ));
54
    }
55
56
    /**
57
     * {@inheritdoc}
58
     */
59 3
    public function unserialize($serialized): void
60
    {
61 3
        list($this->rootPath, $this->machineName, $this->camelCaseMachineName) = \unserialize($serialized);
62 3
    }
63
}
64