1<?php
2
3
4namespace ComboStrap;
5
6
7class InterWikiPath extends PathAbs
8{
9
10
11    public const scheme = 'interwiki';
12
13    private $path;
14
15    /**
16     * InterWikiPath constructor.
17     */
18    public function __construct($path)
19    {
20        if (!media_isexternal($path)) {
21            LogUtility::msg("The path ($path) is not an internet path");
22        }
23        $this->path = $path;
24    }
25
26
27    public static function create(string $path): InterWikiPath
28    {
29        return new InterWikiPath($path);
30    }
31
32    function getScheme(): string
33    {
34        return self::scheme;
35    }
36
37    function getLastName()
38    {
39        return $this->getNames()[0];
40    }
41
42    function getNames(): array
43    {
44        $sepPosition = strpos(">", $this->path);
45        return [substr($this->path, $sepPosition)];
46    }
47
48    function getParent(): ?Path
49    {
50        return null;
51    }
52
53
54    function toString(): string
55    {
56        return $this->path;
57    }
58
59    function toAbsolutePath(): Path
60    {
61        return new InterWikiPath($this->path);
62    }
63
64    /**
65     *
66     */
67    function resolve(string $name): InterWikiPath
68    {
69        return self::create($this->path . "/" . $name);
70    }
71}
72