1 | <?php |
||
5 | class Stub |
||
6 | { |
||
7 | /** |
||
8 | * The base path of stub file. |
||
9 | * |
||
10 | * @var null|string |
||
11 | */ |
||
12 | protected static $basePath = null; |
||
13 | /** |
||
14 | * The stub path. |
||
15 | * |
||
16 | * @var string |
||
17 | */ |
||
18 | protected $path; |
||
19 | /** |
||
20 | * The replacements array. |
||
21 | * |
||
22 | * @var array |
||
23 | */ |
||
24 | protected $replaces = []; |
||
25 | |||
26 | /** |
||
27 | * The contructor. |
||
28 | * |
||
29 | * @param string $path |
||
30 | * @param array $replaces |
||
31 | */ |
||
32 | public function __construct($path, array $replaces = []) |
||
37 | |||
38 | /** |
||
39 | * Create new self instance. |
||
40 | * |
||
41 | * @param string $path |
||
42 | * @param array $replaces |
||
43 | * |
||
44 | * @return self |
||
45 | */ |
||
46 | public static function create($path, array $replaces = []) |
||
50 | |||
51 | /** |
||
52 | * Set base path. |
||
53 | * |
||
54 | * @param string $path |
||
55 | * |
||
56 | * @return void |
||
57 | */ |
||
58 | public static function setBasePath($path) |
||
62 | |||
63 | /** |
||
64 | * Set replacements array. |
||
65 | * |
||
66 | * @param array $replaces |
||
67 | * |
||
68 | * @return $this |
||
69 | */ |
||
70 | public function replace(array $replaces = []) |
||
76 | |||
77 | /** |
||
78 | * Get replacements. |
||
79 | * |
||
80 | * @return array |
||
81 | */ |
||
82 | public function getReplaces() |
||
86 | |||
87 | /** |
||
88 | * Handle magic method __toString. |
||
89 | * |
||
90 | * @return string |
||
91 | */ |
||
92 | public function __toString() |
||
96 | |||
97 | /** |
||
98 | * Get stub contents. |
||
99 | * |
||
100 | * @return string |
||
101 | */ |
||
102 | public function render() |
||
106 | |||
107 | /** |
||
108 | * Get stub contents. |
||
109 | * |
||
110 | * @return string |
||
111 | */ |
||
112 | public function getContents() |
||
121 | |||
122 | /** |
||
123 | * Get stub path. |
||
124 | * |
||
125 | * @return string |
||
126 | */ |
||
127 | public function getPath() |
||
131 | |||
132 | /** |
||
133 | * Set stub path. |
||
134 | * |
||
135 | * @param string $path |
||
136 | * |
||
137 | * @return self |
||
138 | */ |
||
139 | public function setPath($path) |
||
145 | } |
||
146 |