4
4
5
5
use Illuminate \Console \Command ;
6
6
7
- abstract class CommandGenerator extends Command{
8
-
7
+ abstract class CommandGenerator extends Command
8
+ {
9
+
9
10
/**
10
11
* argumentName
11
12
*
12
13
* @var mixed
13
14
*/
14
15
public $ argumentName ;
15
-
16
+
16
17
/**
17
18
* Return the rendered File Content
18
19
* getTemplateContents
19
20
*
20
21
* @return string
21
22
*/
22
23
abstract protected function getTemplateContents ();
23
-
24
+
24
25
25
26
/**
26
27
* Return the destination path for publishe created class file.
@@ -29,32 +30,41 @@ abstract protected function getTemplateContents();
29
30
* @return string
30
31
*/
31
32
abstract protected function getDestinationFilePath ();
32
-
33
+
34
+
35
+ /**
36
+ * Get Namespace From Config
37
+ * @return string
38
+ */
39
+ public function getNamespaceFromConfig (): string
40
+ {
41
+ return config ('laravel-more-command.namespace ' ) ?? 'App ' ;
42
+ }
33
43
34
44
/**
35
45
* Return the default namesapce for class
36
46
* getDefaultNamespace
37
47
*
38
48
* @return string
39
49
*/
40
- public function getDefaultNamespace () : string
50
+ public function getDefaultNamespace (): string
41
51
{
42
52
return '' ;
43
53
}
44
54
45
-
55
+
46
56
/**
47
57
* Return the default namesapce type for interface
48
58
* getDefaultInterfaceNamespace
49
59
*
50
60
* @return string
51
61
*/
52
- public function getDefaultInterfaceNamespace () : string
62
+ public function getDefaultInterfaceNamespace (): string
53
63
{
54
64
return '' ;
55
65
}
56
66
57
-
67
+
58
68
/**
59
69
* Return a vaid class name
60
70
* getClass
@@ -66,7 +76,7 @@ public function getClass()
66
76
return class_basename ($ this ->argument ($ this ->argumentName ));
67
77
}
68
78
69
-
79
+
70
80
/**
71
81
* Generate class namespace dinamacally
72
82
* getClassNamespace
@@ -79,7 +89,7 @@ public function getClassNamespace()
79
89
80
90
$ extra = str_replace ('/ ' , '\\' , $ extra );
81
91
82
- $ namespace = $ this ->getDefaultNamespace ();
92
+ $ namespace = $ this ->getDefaultNamespace ();
83
93
84
94
$ namespace .= '\\' . $ extra ;
85
95
@@ -89,7 +99,6 @@ public function getClassNamespace()
89
99
}
90
100
91
101
92
-
93
102
/**
94
103
* Generate interface namespace dinamacally
95
104
* getInterfaceNamespace
@@ -98,11 +107,11 @@ public function getClassNamespace()
98
107
*/
99
108
public function getInterfaceNamespace ()
100
109
{
101
- $ extra = str_replace ($ this ->getClass (). 'Interface ' , '' , $ this ->argument ($ this ->argumentName ). 'Interface ' );
110
+ $ extra = str_replace ($ this ->getClass () . 'Interface ' , '' , $ this ->argument ($ this ->argumentName ) . 'Interface ' );
102
111
103
112
$ extra = str_replace ('/ ' , '\\' , $ extra );
104
113
105
- $ namespace = $ this ->getDefaultInterfaceNamespace ();
114
+ $ namespace = $ this ->getDefaultInterfaceNamespace ();
106
115
107
116
$ namespace .= '\\' . $ extra ;
108
117
@@ -112,22 +121,19 @@ public function getInterfaceNamespace()
112
121
}
113
122
114
123
115
-
116
124
/**
117
125
* checkModuleExists
118
126
*
119
- * @param mixed $moduleName
127
+ * @param mixed $moduleName
120
128
* @return bool
121
129
*/
122
- public function checkModuleExists (string $ moduleName ):bool
130
+ public function checkModuleExists (string $ moduleName ): bool
123
131
{
124
- if (!in_array ($ moduleName ,scandir (base_path (). "/Modules " ))) {
132
+ if (!in_array ($ moduleName , scandir (base_path () . "/Modules " ))) {
125
133
return false ;
126
134
}
127
135
return true ;
128
136
}
129
137
130
138
131
-
132
-
133
139
}
0 commit comments