JsonPointerAware   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A toJsonPointer() 0 7 2
1
<?php
2
3
namespace Cerbero\LazyJson\Concerns;
4
5
/**
6
 * The JSON pointer aware trait.
7
 *
8
 */
9
trait JsonPointerAware
10
{
11
    /**
12
     * Retrieve a JSON pointer from the given dot-noted path.
13
     *
14
     * @param string $path
15
     * @return string
16
     */
17 10
    protected function toJsonPointer(string $path): string
18
    {
19 10
        if (empty($path = trim($path))) {
20 9
            return '';
21
        }
22
23 1
        return '/' . str_replace(['~', '/', '.', '*'], ['~0', '~1', '/', '-'], $path);
24
    }
25
}
26