1 | <?php |
||
10 | abstract class WorkingWithStubs extends Command |
||
11 | { |
||
12 | /** @var Filesystem */ |
||
13 | protected $files; |
||
14 | |||
15 | /** |
||
16 | * Set all Stubs replaces |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $variables = []; |
||
21 | |||
22 | /** |
||
23 | * @param Filesystem $file |
||
24 | */ |
||
25 | public function __construct(Filesystem $file) |
||
31 | |||
32 | /** |
||
33 | * Get stub content and replace variables, then put it into directory |
||
34 | * |
||
35 | * @param string $stub |
||
36 | * @param string $directory output directory |
||
37 | * @param string $name file name |
||
38 | * @param array $variables |
||
39 | */ |
||
40 | public function createFromStub($stub, $directory, $name, $variables = []) |
||
56 | |||
57 | /** |
||
58 | * Parse the class name and format according to the root namespace. |
||
59 | * |
||
60 | * @param string $name |
||
61 | * @return string |
||
62 | */ |
||
63 | protected function qualifyClass($name) |
||
79 | |||
80 | /** |
||
81 | * Get the default namespace for the class. |
||
82 | * |
||
83 | * @param string $rootNamespace |
||
84 | * @return string |
||
85 | */ |
||
86 | protected function getDefaultNamespace($rootNamespace) |
||
90 | |||
91 | /** |
||
92 | * Get the root namespace for the class. |
||
93 | * |
||
94 | * @return string |
||
95 | */ |
||
96 | protected function rootNamespace() |
||
100 | |||
101 | /** |
||
102 | * Build the directory for the class if necessary. |
||
103 | * |
||
104 | * @param string $path |
||
105 | * @return string |
||
106 | */ |
||
107 | protected function makeDirectory($path) |
||
115 | |||
116 | /** |
||
117 | * Get the desired class name from the input. |
||
118 | * |
||
119 | * @return string |
||
120 | */ |
||
121 | abstract protected function getNameInput(); |
||
122 | } |
||
123 |