KeyQuoterTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 11
c 1
b 0
f 0
dl 0
loc 23
ccs 11
cts 11
cp 1
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A quoteKey() 0 14 2
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