KeyQuoterTrait::quoteKey()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 14
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 10
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 14
ccs 11
cts 11
cp 1
crap 2
rs 9.9332
1
<?php
2
3
/**
4
 * Copyright MediaCT. All rights reserved.
5
 * https://www.mediact.nl
6
 */
7
8
namespace Mediact\DataContainer;
9
10
trait KeyQuoterTrait
11
{
12
    /**
13
     * Quote a key.
14
     *
15
     * @param string $key
16
     *
17
     * @return string
18
     */
19 4
    private function quoteKey(string $key): string
20
    {
21 4
        return strpos($key, DataContainerInterface::SEPARATOR) !== false
22 2
            ? sprintf(
23 2
                '%s%s%s',
24 2
                DataContainerInterface::ENCLOSURE,
25 2
                str_replace(
26 2
                    DataContainerInterface::ENCLOSURE,
27 2
                    DataContainerInterface::ENCLOSURE . DataContainerInterface::ENCLOSURE,
28 2
                    $key
29
                ),
30 2
                DataContainerInterface::ENCLOSURE
31
            )
32 4
            : $key;
33
    }
34
}
35