@@ -9,17 +9,15 @@ class MakeLdapConfig extends Command
99{
1010 /**
1111 * The filesystem instance.
12- *
13- * @var \Illuminate\Filesystem\Filesystem
1412 */
15- protected $ files ;
13+ protected Filesystem $ files ;
1614
1715 /**
1816 * The console command name.
1917 *
2018 * @var string
2119 */
22- protected $ name = 'make:ldap- config ' ;
20+ protected $ name = 'ldap: make:config ' ;
2321
2422 /**
2523 * The console command description.
@@ -30,9 +28,6 @@ class MakeLdapConfig extends Command
3028
3129 /**
3230 * Create a new controller creator command instance.
33- *
34- * @param Filesystem $files
35- * @return void
3631 */
3732 public function __construct (Filesystem $ files )
3833 {
@@ -44,18 +39,22 @@ public function __construct(Filesystem $files)
4439 /**
4540 * Create the LDAP configuration file.
4641 */
47- public function handle ()
42+ public function handle (): int
4843 {
4944 if (! $ this ->files ->exists ($ stubPath = $ this ->getStubPath ())) {
50- return $ this ->error ("Unable to retrieve LDAP configuration stub file from path [ $ stubPath] " );
45+ $ this ->error ("Unable to retrieve LDAP configuration stub file from path [ $ stubPath] " );
46+
47+ return static ::FAILURE ;
5148 }
5249
5350 $ publishPath = $ this ->getLdapConfigPath (
5451 $ configPath = $ this ->getConfigPath ()
5552 );
5653
5754 if ($ this ->alreadyExists ($ publishPath )) {
58- return $ this ->error ("LDAP configuration file already exists at path [ $ publishPath] " );
55+ $ this ->error ("LDAP configuration file already exists at path [ $ publishPath] " );
56+
57+ return static ::INVALID ;
5958 }
6059
6160 if (! $ this ->alreadyExists ($ configPath )) {
@@ -65,67 +64,54 @@ public function handle()
6564 $ this ->files ->put ($ publishPath , $ this ->getContents ($ stubPath ));
6665
6766 $ this ->info ("Successfully created LDAP configuration file at path [ $ publishPath] " );
67+
68+ return static ::SUCCESS ;
6869 }
6970
7071 /**
7172 * Determine if the given file / folder already exists.
72- *
73- * @param string $path
74- * @return bool
7573 */
76- protected function alreadyExists ($ path )
74+ protected function alreadyExists (string $ path ): bool
7775 {
7876 return $ this ->files ->exists ($ path );
7977 }
8078
8179 /**
8280 * Make the given directory path.
83- *
84- * @param string $path
8581 */
86- protected function makeDirectory ($ path )
82+ protected function makeDirectory (string $ path ): void
8783 {
8884 $ this ->files ->makeDirectory ($ path );
8985 }
9086
9187 /**
9288 * Get the contents of the given file.
93- *
94- * @param string $path
95- * @return string
9689 */
97- protected function getContents ($ path )
90+ protected function getContents (string $ path ): string
9891 {
9992 return $ this ->files ->get ($ path );
10093 }
10194
10295 /**
10396 * Get the LDAP configuration file stub.
104- *
105- * @return string
10697 */
107- protected function getStubPath ()
98+ protected function getStubPath (): string
10899 {
109100 return base_path (implode (DIRECTORY_SEPARATOR , ['vendor ' , 'directorytree ' , 'ldaprecord-laravel ' , 'config ' , 'ldap.php ' ]));
110101 }
111102
112103 /**
113104 * Get the configuration folder path.
114- *
115- * @return string
116105 */
117- public function getConfigPath ()
106+ public function getConfigPath (): string
118107 {
119108 return base_path ('config ' );
120109 }
121110
122111 /**
123112 * Get the full LDAP configuration file path.
124- *
125- * @param string $configPath
126- * @return string
127113 */
128- protected function getLdapConfigPath ($ configPath )
114+ protected function getLdapConfigPath (string $ configPath ): string
129115 {
130116 return $ configPath .DIRECTORY_SEPARATOR .'ldap.php ' ;
131117 }
0 commit comments