Passed
Push — develop ( 2651d0...b1c5cd )
by Fabian
01:29
created

AbstractMessage::unserialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cakasim\Payone\Sdk\Notification\Message;
6
7
/**
8
 * The base class for notification messages from PAYONE.
9
 *
10
 * @author Fabian Böttcher <[email protected]>
11
 * @since 0.1.0
12
 */
13
abstract class AbstractMessage implements MessageInterface
14
{
15
    /**
16
     * @var array The message parameters.
17
     */
18
    protected $parameters;
19
20
    /**
21
     * Constructs the message with provided parameters.
22
     *
23
     * @param array $parameters The parameters of the message.
24
     */
25
    public function __construct(array $parameters)
26
    {
27
        $this->parameters = $parameters;
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function serialize(): string
34
    {
35
        return \serialize($this->parameters);
36
    }
37
38
    /**
39
     * @inheritDoc
40
     */
41
    public function unserialize($serialized): void
42
    {
43
        $this->parameters = \unserialize($serialized);
44
    }
45
46
    /**
47
     * Returns the value of the specified parameter.
48
     *
49
     * @param string $name The parameter name.
50
     * @return string|null The parameter value or null if the parameter does not exist.
51
     */
52
    public function getParameter(string $name): ?string
53
    {
54
        return $this->parameters[$name] ?? null;
55
    }
56
}
57