PathPart::getPath()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 0
1
<?php declare(strict_types=1);
2
3
namespace App\Domain;
4
5
final class PathPart
6
{
7
    /** @var string */
8
    private $path;
9
10
    /** @var int */
11
    private $priority;
12
13
    /** @var string[] */
14
    private $substitutions;
15
16
    /**
17
     * @param array $config
18
     */
19
    public function __construct(array $config)
20
    {
21
        $this->path = rtrim($config['path'] ?? '', DIRECTORY_SEPARATOR);
22
        $this->priority = $config['priority'] ?? 0;
23
        $this->substitutions = $config['substitutions'] ?? [];
24
    }
25
26
    /**
27
     * @return string
28
     */
29
    public function getPath(): string
30
    {
31
        return str_replace(array_keys($this->substitutions), array_values($this->substitutions), $this->path);
32
    }
33
34
    /**
35
     * @return int
36
     */
37
    public function getPriority(): int
38
    {
39
        return $this->priority;
40
    }
41
}
42