Completed
Push — 7.4 ( abf332 )
by Nikolaos
16:13
created

AbstractSerializer::setData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * This file is part of the Phalcon Framework.
5
 *
6
 * (c) Phalcon Team <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE.txt
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Phalcon\Storage\Serializer;
15
16
use function is_bool;
17
use function is_numeric;
18
19
/**
20
 * Class AbstractSerializer
21
 *
22
 * @property mixed|null $data
23
 */
24
abstract class AbstractSerializer implements SerializerInterface
25
{
26
    /**
27
     * @var mixed
28
     */
29
    protected $data = null;
30
31
    /**
32
     * AbstractSerializer constructor.
33
     *
34
     * @param null|mixed $data
35
     */
36
    public function __construct($data = null)
37
    {
38
        $this->setData($data);
39
    }
40
41
    /**
42
     * Returns the internal array
43
     *
44
     * @return mixed|null
45
     */
46
    public function getData()
47
    {
48
        return $this->data;
49
    }
50
51
    /**
52
     * Sets the data
53
     *
54
     * @param mixed $data
55
     */
56
    public function setData($data): void
57
    {
58
        $this->data = $data;
59
    }
60
61
    /**
62
     * If this returns true, then the data returns back as is
63
     *
64
     * @param mixed $data
65
     *
66
     * @return bool
67
     */
68
    protected function isSerializable($data): bool
69
    {
70
        return !(empty($data) || is_bool($data) || is_numeric($data));
71
    }
72
}
73