1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* To change this license header, choose License Headers in Project Properties. |
5
|
|
|
* To change this template file, choose Tools | Templates |
6
|
|
|
* and open the template in the editor. |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace Maslosoft\Zamm; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Api Url generator |
13
|
|
|
* |
14
|
|
|
* @author Piotr Maselkowski <pmaselkowski at gmail.com> |
15
|
|
|
*/ |
16
|
|
|
class ApiUrl implements Interfaces\SourceAccessorInterface |
17
|
|
|
{ |
18
|
|
|
|
19
|
|
|
use Traits\SourceMagic; |
20
|
|
|
|
21
|
|
|
private static $source = ''; |
22
|
|
|
private $dotName = ''; |
23
|
|
|
|
24
|
|
|
public function __construct($className = null, $text = '') |
25
|
|
|
{ |
26
|
|
|
$this->dotName = str_replace('\\', '.', $className); |
27
|
|
|
} |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* Set root url of current project API. This can be relative or absolute url. |
31
|
|
|
* |
32
|
|
|
* Example: |
33
|
|
|
* |
34
|
|
|
* ``` |
35
|
|
|
* ApiUrl::setRoot('/mangan/api); |
36
|
|
|
* ``` |
37
|
|
|
* |
38
|
|
|
* @param string $apiUrl |
39
|
|
|
*/ |
40
|
|
|
public static function setRoot($apiUrl) |
41
|
|
|
{ |
42
|
|
|
self::$source = rtrim($apiUrl, '/'); |
43
|
|
|
} |
44
|
|
|
|
45
|
|
|
public function method($name) |
46
|
|
|
{ |
47
|
|
|
// https://df.home/zamm/api/class-Maslosoft.Zamm.Decorators.AbstractDecorator.html#_decorate |
48
|
|
|
return sprintf('%s/class-%s.html#_%s', self::$source, $this->dotName, $name); |
49
|
|
|
} |
50
|
|
|
|
51
|
|
|
public function property($name) |
52
|
|
|
{ |
53
|
|
|
// https://df.home/zamm/api/class-Maslosoft.Zamm.Zamm.html#$decorators |
54
|
|
|
return sprintf('%s/class-%s.html#$%s', self::$source, $this->dotName, $name); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
public static function __callStatic($name, $arguments) |
58
|
|
|
{ |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
public function __toString() |
63
|
|
|
{ |
64
|
|
|
return sprintf('%s/class-%s.html', self::$source, $this->dotName); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
} |
68
|
|
|
|