diff src/Generator/Controller/ControllerGenerator.php @ 21:f0b0d014e448 main-dev

Cleaning up code based on AI overlord review
author Luka Sitas <sitas.luka.97@gmail.com>
date Wed, 26 Feb 2025 19:45:08 -0500
parents 19b7a8de0019
children ee8ef14e158d
line wrap: on
line diff
--- a/src/Generator/Controller/ControllerGenerator.php	Wed Feb 26 19:29:55 2025 -0500
+++ b/src/Generator/Controller/ControllerGenerator.php	Wed Feb 26 19:45:08 2025 -0500
@@ -31,8 +31,10 @@
 
     /**
      * Execute the console command.
+     *
+     * @return void
      */
-    public function handle()
+    public function handle(): void
     {
         parent::handle();
     }
@@ -42,7 +44,7 @@
      *
      * @return string
      */
-    protected function getStub()
+    protected function getStub(): string
     {
         return $this->resolveStubPath('/stubs/controller.stub');
     }
@@ -51,28 +53,38 @@
      * Resolve the fully-qualified path to the stub.
      *
      * @param string $stub
+     * @return string
+     */
+    protected function resolveStubPath(string $stub): string
+    {
+        $customPath = $this->laravel->basePath(trim($stub, '/'));
+
+        return is_file($customPath) ? $customPath : __DIR__ . $stub;
+    }
+
+    /**
+     * Get the path for the generated file.
      *
+     * @param string|null $name
      * @return string
      */
-    protected function resolveStubPath($stub)
+    protected function getPath(?string $name = null): string
     {
-        return is_file($customPath = $this->laravel->basePath(trim($stub, '/')))
-            ? $customPath
-            : __DIR__.$stub;
+        return str_replace(
+            ['App\\', '\\'],
+            ['app/', '/'],
+            $this->getControllerNamespace() . '/' . $this->controller_name($this->getTableInput()) . '.php'
+        );
     }
 
-    protected function getClassName($name)
+    /**
+     * Get the class name for the controller.
+     *
+     * @param string $name
+     * @return string
+     */
+    protected function getClassName(string $name): string
     {
         return $this->controller_name($name);
     }
-
-    /**
-     * Get the stub file for the generator.
-     *
-     * @return string
-     */
-    protected function getPath($name = null)
-    {
-        return str_replace(['App\\', '\\'], ['app/', '/'], $this->getControllerNamespace().'/'.$this->controller_name($this->getTableInput()).'.php');
-    }
 }