Passed
Push — master ( 3c5f34...4a3ec6 )
by Asmir
01:27 queued 50s
created

PropertyMetadata   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 3
Bugs 1 Features 0
Metric Value
eloc 10
dl 0
loc 31
ccs 8
cts 8
cp 1
rs 10
c 3
b 1
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A serializeToArray() 0 5 1
A unserializeFromArray() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Metadata;
6
7
/**
8
 * Base class for property metadata.
9
 *
10
 * This class is intended to be extended to add your application specific
11
 * properties, and flags.
12
 *
13
 * @author Johannes M. Schmitt <[email protected]>
14
 */
15
class PropertyMetadata implements \Serializable
16
{
17
    use SerializationHelper;
18
19
    /**
20
     * @var string
21
     */
22
    public $class;
23
24
    /**
25
     * @var string
26
     */
27 3
    public $name;
28
29 3
    public function __construct(string $class, string $name)
30 3
    {
31 3
        $this->class = $class;
32
        $this->name = $name;
33
    }
34
35
    protected function serializeToArray(): array
36
    {
37
        return [
38
            $this->class,
39
            $this->name,
40 1
        ];
41
    }
42 1
43 1
    protected function unserializeFromArray(array $data): void
44 1
    {
45
        [$this->class, $this->name] = $data;
46
    }
47
}
48