Passed
Push — master ( c052ad...705b31 )
by Bingo
02:51
created

AbstractEscaper::escape()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 3.3332

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 11
ccs 4
cts 6
cp 0.6667
crap 3.3332
rs 10
1
<?php
2
3
namespace PhpDocxTemplate\Escaper;
4
5
abstract class AbstractEscaper implements EscaperInterface
6
{
7
    /**
8
     * @param string $input
9
     *
10
     * @return string
11
     */
12
    abstract protected function escapeSingleValue(string $input): string;
13
14
    /**
15
     * @param mixed $input
16
     *
17
     * @return mixed
18
     */
19 1
    public function escape($input)
20
    {
21 1
        if (is_array($input)) {
22
            foreach ($input as &$item) {
23
                $item = $this->escapeSingleValue($item);
24
            }
25
        } else {
26 1
            $input = $this->escapeSingleValue($input);
27
        }
28
29 1
        return $input;
30
    }
31
}
32