/
Prepend.php
54 lines (47 loc) · 1.15 KB
/
Prepend.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
<?php
namespace Evoke\HTTP\URI\Rule;
/** A rule to prepend a string to the classname.
* No parameters are matched by this class.
*/
class Prepend extends Base
{
/** @property $str
* \string String to prepend to the classname.
*/
protected $str;
/** Construct the prepend rule.
* @param str \string The string to prepend.
* @param authoritative \bool Whether the rule can definitely give the
* final route for all URIs that it matches.
*/
public function __construct(/* String */ $str,
/* Bool */ $authoritative = false)
{
if (!is_string($str))
{
throw new \InvalidArgumentException(
__METHOD__ . ' requires str as string');
}
parent::__construct($authoritative);
$this->str = $str;
}
/******************/
/* Public Methods */
/******************/
/** Get the classname.
* @param uri \string The URI to get the classname from.
* @return \string The uri with the string prepended.
*/
public function getClassname($uri)
{
return $this->str . $uri;
}
/** The prepend rule always matches.
* @return \bool TRUE.
*/
public function isMatch($uri)
{
return true;
}
}
// EOF