7
7
use DragonCode \Support \Facades \Filesystem \File ;
8
8
use DragonCode \Support \Facades \Filesystem \Path ;
9
9
use DragonCode \Support \Facades \Helpers \Str ;
10
+ use DragonCode \Support \Helpers \Ables \Stringable ;
10
11
11
12
use function base_path ;
12
13
use function date ;
@@ -21,14 +22,26 @@ class Make extends Processor
21
22
22
23
public function handle (): void
23
24
{
24
- $ pathWithName = $ this ->getPath ().$ this ->getName ();
25
+ $ this ->notification ->task ($ this ->message (), fn () => $ this ->create ());
26
+ }
25
27
26
- $ this ->notification ->task ('Creating an operation [ ' .$ pathWithName .'] ' , fn () => $ this ->create ($ pathWithName ));
28
+ protected function message (): string
29
+ {
30
+ return 'Operation [ ' . $ this ->displayName ($ this ->getFullPath ()) . '] created successfully ' ;
27
31
}
28
32
29
- protected function create (string $ path ): void
33
+ protected function create (): void
30
34
{
31
- File::copy ($ this ->stubPath (), $ path );
35
+ File::copy ($ this ->stubPath (), $ this ->getFullPath ());
36
+ }
37
+
38
+ protected function displayName (string $ path ): string
39
+ {
40
+ return Str::of ($ path )
41
+ ->when (! $ this ->showFullPath (), fn (Stringable $ str ) => $ str ->after (base_path ()))
42
+ ->replace ('\\' , '/ ' )
43
+ ->ltrim ('./ ' )
44
+ ->toString ();
32
45
}
33
46
34
47
protected function getName (): string
@@ -43,6 +56,11 @@ protected function getPath(): string
43
56
return $ this ->options ->path ;
44
57
}
45
58
59
+ protected function getFullPath (): string
60
+ {
61
+ return $ this ->getPath () . $ this ->getName ();
62
+ }
63
+
46
64
protected function getFilename (string $ branch ): string
47
65
{
48
66
$ directory = Path::dirname ($ branch );
@@ -53,6 +71,7 @@ protected function getFilename(string $branch): string
53
71
->prepend ($ this ->getTime ())
54
72
->finish ('.php ' )
55
73
->prepend ($ directory . '/ ' )
74
+ ->replace ('\\' , '/ ' )
56
75
->ltrim ('./ ' )
57
76
->toString ();
58
77
}
@@ -95,4 +114,9 @@ protected function stubPath(): string
95
114
96
115
return $ this ->defaultStub ;
97
116
}
117
+
118
+ protected function showFullPath (): bool
119
+ {
120
+ return $ this ->config ->showFullPath ();
121
+ }
98
122
}
0 commit comments