@@ -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,7 +21,7 @@ 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
@@ -34,7 +33,6 @@ public function getClassFromFile($file)
3433
3534 /**
3635 * @param ReflectionClass $class
37- *
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
51+ * Check if the class implements the CRUD methods.
5352 *
5453 * @param ReflectionClass $class
55- *
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
79+ * and have a dependency on a model.
8280 *
8381 * @param ReflectionClass $class
84- *
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"
91+ * A service class must have a name ending with "Service" or "EloquentService".
9592 *
9693 * @param ReflectionClass $class
97- *
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
105+ * and have a dependency on a model.
110106 *
111107 * @param ReflectionClass $class
112- *
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"
117+ * An action class must have a name ending with "Action" or "EloquentAction".
123118 *
124119 * @param ReflectionClass $class
125- *
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 *
137131 * @param ReflectionClass $class
138132 * @param $type
139- *
140133 * @return bool
141134 */
142135 protected function checkClassType (ReflectionClass $ class , $ type )
143136 {
144137 $ type = ucfirst ($ type );
138+
145139 return preg_match ('/ ' .$ type .'$/ ' , $ class ->getName ()) === 1
146140 || 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
146+ * Get the type of the given class.
153147 *
154148 * @param ReflectionClass $class
155- *
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