1 | <?php |
||
5 | class Stub |
||
6 | { |
||
7 | /** |
||
8 | * The stub path. |
||
9 | * |
||
10 | * @var string |
||
11 | */ |
||
12 | protected $path; |
||
13 | |||
14 | /** |
||
15 | * The base path of stub file. |
||
16 | * |
||
17 | * @var null|string |
||
18 | */ |
||
19 | protected static $basePath = null; |
||
20 | |||
21 | /** |
||
22 | * The replacements array. |
||
23 | * |
||
24 | * @var array |
||
25 | */ |
||
26 | protected $replaces = []; |
||
27 | |||
28 | /** |
||
29 | * The contructor. |
||
30 | * |
||
31 | * @param string $path |
||
32 | * @param array $replaces |
||
33 | */ |
||
34 | 31 | public function __construct($path, array $replaces = []) |
|
39 | |||
40 | /** |
||
41 | * Create new self instance. |
||
42 | * |
||
43 | * @param string $path |
||
44 | * @param array $replaces |
||
45 | * |
||
46 | * @return self |
||
47 | */ |
||
48 | 2 | public static function create($path, array $replaces = []) |
|
52 | |||
53 | /** |
||
54 | * Create new self instance from full path. |
||
55 | * |
||
56 | * @param string $path |
||
57 | * @param array $replaces |
||
58 | * |
||
59 | * @return self |
||
60 | */ |
||
61 | public static function createFromPath($path, array $replaces = []) |
||
69 | |||
70 | /** |
||
71 | * Set stub path. |
||
72 | * |
||
73 | * @param string $path |
||
74 | * |
||
75 | * @return self |
||
76 | */ |
||
77 | public function setPath($path) |
||
83 | |||
84 | /** |
||
85 | * Get stub path. |
||
86 | * |
||
87 | * @return string |
||
88 | */ |
||
89 | 31 | public function getPath() |
|
93 | |||
94 | /** |
||
95 | * Set base path. |
||
96 | * |
||
97 | * @param string $path |
||
98 | */ |
||
99 | 73 | public static function setBasePath($path) |
|
103 | |||
104 | /** |
||
105 | * Get base path. |
||
106 | * |
||
107 | * @return string|null |
||
108 | */ |
||
109 | 31 | public static function getBasePath() |
|
113 | |||
114 | /** |
||
115 | * Get stub contents. |
||
116 | * |
||
117 | * @return mixed|string |
||
118 | */ |
||
119 | 31 | public function getContents() |
|
129 | |||
130 | /** |
||
131 | * Get stub contents. |
||
132 | * |
||
133 | * @return string |
||
134 | */ |
||
135 | 31 | public function render() |
|
139 | |||
140 | /** |
||
141 | * Save stub to specific path. |
||
142 | * |
||
143 | * @param string $path |
||
144 | * @param string $filename |
||
145 | * |
||
146 | * @return bool |
||
147 | */ |
||
148 | public function saveTo($path, $filename) |
||
152 | |||
153 | /** |
||
154 | * Set replacements array. |
||
155 | * |
||
156 | * @param array $replaces |
||
157 | * |
||
158 | * @return $this |
||
159 | */ |
||
160 | public function replace(array $replaces = []) |
||
166 | |||
167 | /** |
||
168 | * Get replacements. |
||
169 | * |
||
170 | * @return array |
||
171 | */ |
||
172 | public function getReplaces() |
||
176 | |||
177 | /** |
||
178 | * Handle magic method __toString. |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | 2 | public function __toString() |
|
186 | } |
||
187 |