@@ -12,7 +12,6 @@ class DetectController extends Controller
1212{
1313 /**
1414 * @param $file
15- *
1615 * @return ReflectionClass|null
1716 */
1817 public function getClassFromFile ($ file )
@@ -22,19 +21,18 @@ public function getClassFromFile($file)
2221
2322 // Match namespace and class name
2423 preg_match ('/namespace\s+(.*?);.*?class\s+(\w+)/s ' , $ content , $ matches );
25- if (!isset ($ matches [1 ]) || !isset ($ matches [2 ])) {
24+ if (! isset ($ matches [1 ]) || ! isset ($ matches [2 ])) {
2625 return null ;
2726 }
2827
2928 $ namespace = $ matches [1 ];
30- $ class = $ namespace . '\\' . $ matches [2 ];
29+ $ class = $ namespace. '\\' . $ matches [2 ];
3130
3231 return class_exists ($ class ) ? new ReflectionClass ($ class ) : null ;
3332 }
3433
3534 /**
36- * @param ReflectionClass $class
37- *
35+ * @param ReflectionClass $class
3836 * @return bool
3937 */
4038 private function dependsOnModels (ReflectionClass $ class )
@@ -45,14 +43,14 @@ private function dependsOnModels(ReflectionClass $class)
4543 return true ;
4644 }
4745 }
46+
4847 return false ;
4948 }
5049
5150 /**
52- * Check if the class implements the CRUD methods
53- *
54- * @param ReflectionClass $class
51+ * Check if the class implements the CRUD methods.
5552 *
53+ * @param ReflectionClass $class
5654 * @return bool
5755 */
5856 protected function implementsCrudMethods (ReflectionClass $ class )
@@ -62,7 +60,7 @@ protected function implementsCrudMethods(ReflectionClass $class)
6260 'create ' ,
6361 'read ' ,
6462 'update ' ,
65- 'delete '
63+ 'delete ' ,
6664 ];
6765
6866 foreach ($ methods as $ method ) {
@@ -78,10 +76,9 @@ protected function implementsCrudMethods(ReflectionClass $class)
7876 * Check if the class is a repository class
7977 * A repository class must have a name ending with "Repository" or "EloquentRepository"
8078 * and implement the CRUD methods
81- * and have a dependency on a model
82- *
83- * @param ReflectionClass $class
79+ * and have a dependency on a model.
8480 *
81+ * @param ReflectionClass $class
8582 * @return bool
8683 */
8784 public function isRepositoryClass (ReflectionClass $ class )
@@ -91,10 +88,9 @@ public function isRepositoryClass(ReflectionClass $class)
9188
9289 /**
9390 * Check if the class is a service class
94- * A service class must have a name ending with "Service" or "EloquentService"
95- *
96- * @param ReflectionClass $class
91+ * A service class must have a name ending with "Service" or "EloquentService".
9792 *
93+ * @param ReflectionClass $class
9894 * @return bool
9995 */
10096 public function isServiceClass (ReflectionClass $ class )
@@ -106,10 +102,9 @@ public function isServiceClass(ReflectionClass $class)
106102 * Check if the class is a controller class
107103 * A controller class must have a name ending with "Controller" or "EloquentController"
108104 * and implement the CRUD methods
109- * and have a dependency on a model
110- *
111- * @param ReflectionClass $class
105+ * and have a dependency on a model.
112106 *
107+ * @param ReflectionClass $class
113108 * @return bool
114109 */
115110 public function isControllerClass (ReflectionClass $ class )
@@ -119,10 +114,9 @@ public function isControllerClass(ReflectionClass $class)
119114
120115 /**
121116 * Check if the class is an action class
122- * An action class must have a name ending with "Action" or "EloquentAction"
123- *
124- * @param ReflectionClass $class
117+ * An action class must have a name ending with "Action" or "EloquentAction".
125118 *
119+ * @param ReflectionClass $class
126120 * @return bool
127121 */
128122 public function isActionClass (ReflectionClass $ class )
@@ -132,27 +126,26 @@ public function isActionClass(ReflectionClass $class)
132126
133127 /**
134128 * Check if the class is a class of the given type
135- * A class of the given type must have a name ending with the given type or "Eloquent" + the given type
129+ * A class of the given type must have a name ending with the given type or "Eloquent" + the given type.
136130 *
137- * @param ReflectionClass $class
131+ * @param ReflectionClass $class
138132 * @param $type
139- *
140133 * @return bool
141134 */
142135 protected function checkClassType (ReflectionClass $ class , $ type )
143136 {
144137 $ type = ucfirst ($ type );
145- return preg_match ('/ ' . $ type . '$/ ' , $ class ->getName ()) === 1
146- || preg_match ('/Eloquent ' . $ type . '$/ ' , $ class ->getName ()) === 1
138+
139+ return preg_match ('/ ' .$ type .'$/ ' , $ class ->getName ()) === 1
140+ || preg_match ('/Eloquent ' .$ type .'$/ ' , $ class ->getName ()) === 1
147141 && $ this ->implementsCrudMethods ($ class )
148142 && $ this ->dependsOnModels ($ class );
149143 }
150144
151145 /**
152- * Get the type of the given class
153- *
154- * @param ReflectionClass $class
146+ * Get the type of the given class.
155147 *
148+ * @param ReflectionClass $class
156149 * @return string
157150 */
158151 protected function getClassType (ReflectionClass $ class )
@@ -178,7 +171,7 @@ protected function getClassType(ReflectionClass $class)
178171 }
179172
180173 /**
181- * Get the type of all classes in the app folder
174+ * Get the type of all classes in the app folder.
182175 *
183176 * @return array[]
184177 */
@@ -189,7 +182,7 @@ public function detect()
189182 $ type = [];
190183
191184 foreach ($ files as $ file ) {
192- if (!$ file ->isFile () || $ file ->getExtension () !== 'php ' ) {
185+ if (! $ file ->isFile () || $ file ->getExtension () !== 'php ' ) {
193186 continue ;
194187 }
195188
0 commit comments