Dot   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 1 1
A toJsonPointer() 0 6 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Cerbero\JsonApiError\Data;
6
7
/**
8
 * The dot-notation value object.
9
 */
10
final class Dot
11
{
12
    /**
13
     * Instantiate the class.
14
     */
15 3
    public function __construct(public readonly string $dot) {}
16
17
    /**
18
     * Retrieve the dot converted into a JSON pointer.
19
     */
20 3
    public function toJsonPointer(): string
21
    {
22 3
        $search = ['~', '/', '.', '*', '\\', '"'];
23 3
        $replace = ['~0', '~1', '/', '-', '\\\\', '\"'];
24
25 3
        return $this->dot == '*' ? '' : '/' . str_replace($search, $replace, $this->dot);
26
    }
27
}
28