classmetadata   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Test Coverage

Coverage 94.12%

Importance

Changes 4
Bugs 0 Features 0
Metric Value
eloc 25
dl 0
loc 42
ccs 16
cts 17
cp 0.9412
rs 10
c 4
b 0
f 0
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get_schema_properties() 0 18 4
A __sleep() 0 5 1
1
<?php
2
/**
3
 * @author CONTENT CONTROL http://www.contentcontrol-berlin.de/
4
 * @copyright CONTENT CONTROL http://www.contentcontrol-berlin.de/
5
 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License
6
 */
7
namespace midgard\portable\mapping;
8
9
use Doctrine\ORM\Mapping\ClassMetadata as base_metadata;
10
11
class classmetadata extends base_metadata
12
{
13
    public array $midgard = [
14
        'parent' => null,
15
        'parentfield' => null,
16
        'upfield' => null,
17
        'unique_fields' => [],
18
        'childtypes' => [],
19
        'field_aliases' => [],
20
        'field_order' => [],
21
        'links_as_entities' => false
22
    ];
23
24 12
    public function __sleep()
25
    {
26 12
        $serialized = parent::__sleep();
27 12
        $serialized[] = 'midgard';
28 12
        return $serialized;
29
    }
30
31
    /**
32
     * @param boolean $metadata Return metadata properties instead
33
     * @return string[]
34
     */
35 1
    public function get_schema_properties(bool $metadata = false) : array
36
    {
37 1
        if ($metadata === true) {
38 1
            $metadata = 0;
39
        }
40 1
        $properties = array_filter($this->midgard['field_order'], function($input) use ($metadata) {
41 1
            if (strpos($input, 'metadata_') === $metadata) {
42 1
                return $input;
43
            }
44 1
        });
45 1
        if ($metadata === false) {
46 1
            $properties[] = 'metadata';
47
        } else {
48 1
            $properties = array_map(function($input) {
49
                return str_replace('metadata_', '', $input);
50 1
            }, $properties);
51
        }
52 1
        return $properties;
53
    }
54
}
55