Total Complexity | 3 |
Total Lines | 42 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
16 | class Versioned implements VersionedInterface |
||
17 | { |
||
18 | /** |
||
19 | * @var string |
||
20 | */ |
||
21 | protected string $version = ''; |
||
22 | |||
23 | /** |
||
24 | * @var string |
||
25 | */ |
||
26 | protected string $format = ''; |
||
27 | |||
28 | /** |
||
29 | * Versioned constructor. |
||
30 | * |
||
31 | * @param string $version |
||
32 | * @param string $format |
||
33 | */ |
||
34 | public function __construct(string $version, string $format = "%s?%s") |
||
35 | { |
||
36 | $this->version = $version; |
||
37 | $this->format = $format; |
||
38 | } |
||
39 | |||
40 | /** |
||
41 | * @inheritdoc |
||
42 | */ |
||
43 | public function applyVersion(string $asset): string |
||
44 | { |
||
45 | return preg_replace( |
||
46 | '#\/{2,}#', |
||
47 | '/', |
||
48 | sprintf($this->format, $asset, $this->version()) |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * @inheritdoc |
||
54 | */ |
||
55 | public function version(): string |
||
58 | } |
||
59 | } |
||
60 |