1 | <?php |
||
10 | abstract class GeneratorCommand extends BaseCommand |
||
11 | { |
||
12 | /** |
||
13 | * $generator. |
||
14 | * |
||
15 | * @var \Recca0120\Generator\Generator |
||
16 | */ |
||
17 | protected $generator; |
||
18 | |||
19 | /** |
||
20 | * Create a new controller creator command instance. |
||
21 | * |
||
22 | * @param \Illuminate\Filesystem\Filesystem $files |
||
23 | * @param \Recca0120\Generator\Generator |
||
24 | */ |
||
25 | 6 | public function __construct(Filesystem $files, Generator $generator) |
|
30 | |||
31 | /** |
||
32 | * Parse the class name and format according to the root namespace. |
||
33 | * |
||
34 | * @param string $name |
||
35 | * @return string |
||
36 | */ |
||
37 | protected function qualifyClass($name) |
||
38 | { |
||
39 | $rootNamespace = $this->rootNamespace(); |
||
40 | |||
41 | if (Str::startsWith($name, $rootNamespace)) { |
||
42 | return $name; |
||
43 | } |
||
44 | |||
45 | $name = str_replace('/', '\\', $name); |
||
46 | |||
47 | return $this->qualifyClass( |
||
48 | $this->getDefaultNamespace(trim($rootNamespace, '\\')).'\\'.$name |
||
49 | ); |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Get the root namespace for the class. |
||
54 | * |
||
55 | * @return string |
||
56 | */ |
||
57 | 3 | protected function rootNamespace() |
|
61 | } |
||
62 |