AbstractXmlMapper::cdata()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 2
ccs 0
cts 0
cp 0
rs 10
c 0
b 0
f 0
cc 2
eloc 1
nc 2
nop 1
crap 6
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace KingsonDe\Marshal;
6
7
/**
8
 * Concrete Mapper classes MUST implement a "map" function that must return an array or null.
9
 * The reason of not having an abstract function for the "map" function is type hinting.
10
 */
11
class AbstractXmlMapper extends AbstractMapper {
12
13 1
    protected function attributes(): string {
14 1
        return MarshalXml::ATTRIBUTES_KEY;
15
    }
16
17 1
    protected function data(): string {
18 1
        return MarshalXml::DATA_KEY;
19
    }
20
21 1
    /**
22 1
     * @param mixed $data
23
     * @return array|string
24
     */
25
    protected function cdata($data = null) {
26
        return ($data ? [MarshalXml::CDATA_KEY => $data] : MarshalXml::CDATA_KEY);
27
    }
28
}
29