-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPath.class.php
More file actions
58 lines (51 loc) · 890 Bytes
/
Path.class.php
File metadata and controls
58 lines (51 loc) · 890 Bytes
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
<?php
/**
* NAME:
* Path
*
* DESCRIPTION:
*
* - Path class represents a valid path
*
*/
class Path
{
protected $_path = '';
/**
* constructor
*
* @param $str path string
*/
public function __construct($str)
{
$this->_path = $this->_clean($str);
}
/**
* return the path value
*
* @return string
*/
public function getPath()
{
return $this->_path;
}
/**
* match the current path with give pattern
*
* @return bool
*/
public function match(Pattern $pattern)
{
return $pattern->match($this->path);
}
//* implementation
/**
* remove whitespace and slash chars
*
* slash char is ignorable
*/
protected function _clean($str)
{
return trim($str, " \t\n\r\0\x0B/");
}
}