-
Notifications
You must be signed in to change notification settings - Fork 0
/
URN.php
62 lines (57 loc) · 1.37 KB
/
URN.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/**
* Base class for URNs.
*
* URNs are essentially identical to URIs (being a subset) with the various logical constraints and the practical difference that they offer a urn() method.
* @author Errol Sayre
* @package ELSWAK
*/
class ELSWAK_URN
extends ELSWAK_URI {
protected $pathComponents;
/**
* Override to redirect to path
* @param string $string hierarchy string
* @return ELSWAK_URN self
*/
public function setHierarchy($string) {
return $this->setPath($string);
}
public function hierarchy() {
return $this->path();
}
/**
* Override the set path method to break the string into components.
* @return ELSWAK_URN self
*/
public function setPath($path) {
return $this->setPathComponents(explode(':', $path));
}
public function path() {
return implode(':', $this->pathComponents());
}
public function hasPath() {
return count($this->pathComponents()) > 0;
}
public function setPathComponents(array $pathComponents = null) {
if (is_array($pathComponents)) {
$this->pathComponents = array_values($pathComponents);
} else {
$this->pathComponents = array();
}
return $this;
}
public function pathComponents() {
if (!is_array($this->pathComponents)) {
$this->pathComponents = array();
}
return $this->pathComponents;
}
/**
* Alias uri()
* @return string
*/
public function urn() {
return $this->uri();
}
}