77use DragonCode \Support \Facades \Filesystem \File ;
88use DragonCode \Support \Facades \Filesystem \Path ;
99use DragonCode \Support \Facades \Helpers \Str ;
10+ use DragonCode \Support \Helpers \Ables \Stringable ;
1011
1112use function base_path ;
1213use function date ;
@@ -21,34 +22,47 @@ class Make extends Processor
2122
2223 public function handle (): void
2324 {
24- $ this ->notification ->task ('Creating an operation ' , fn () => $ this ->run ());
25+ $ fullPath = $ this ->getFullPath ();
26+
27+ $ this ->notification ->task ($ this ->message ($ fullPath ), fn () => $ this ->create ($ fullPath ));
2528 }
2629
27- protected function run ( ): void
30+ protected function message ( string $ path ): string
2831 {
29- $ name = $ this ->getName ();
30- $ path = $ this ->getPath ();
31-
32- $ this ->create ($ path . '/ ' . $ name );
32+ return 'Operation [ ' . $ this ->displayName ($ path ) . '] created successfully ' ;
3333 }
3434
3535 protected function create (string $ path ): void
3636 {
3737 File::copy ($ this ->stubPath (), $ path );
3838 }
3939
40- protected function getName ( ): string
40+ protected function displayName ( string $ path ): string
4141 {
42- $ branch = $ this ->getBranchName ();
42+ return Str::of ($ path )
43+ ->when (! $ this ->showFullPath (), fn (Stringable $ str ) => $ str ->after (base_path ()))
44+ ->replace ('\\' , '/ ' )
45+ ->ltrim ('./ ' )
46+ ->toString ();
47+ }
4348
44- return $ this ->getFilename ($ branch );
49+ protected function getName (): string
50+ {
51+ return $ this ->getFilename (
52+ $ this ->getBranchName ()
53+ );
4554 }
4655
4756 protected function getPath (): string
4857 {
4958 return $ this ->options ->path ;
5059 }
5160
61+ protected function getFullPath (): string
62+ {
63+ return $ this ->getPath () . $ this ->getName ();
64+ }
65+
5266 protected function getFilename (string $ branch ): string
5367 {
5468 $ directory = Path::dirname ($ branch );
@@ -59,6 +73,8 @@ protected function getFilename(string $branch): string
5973 ->prepend ($ this ->getTime ())
6074 ->finish ('.php ' )
6175 ->prepend ($ directory . '/ ' )
76+ ->replace ('\\' , '/ ' )
77+ ->ltrim ('./ ' )
6278 ->toString ();
6379 }
6480
@@ -100,4 +116,9 @@ protected function stubPath(): string
100116
101117 return $ this ->defaultStub ;
102118 }
119+
120+ protected function showFullPath (): bool
121+ {
122+ return $ this ->config ->showFullPath ();
123+ }
103124}
0 commit comments