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,34 +22,47 @@ class Make extends Processor
21
22
22
23
public function handle (): void
23
24
{
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 ));
25
28
}
26
29
27
- protected function run ( ): void
30
+ protected function message ( string $ path ): string
28
31
{
29
- $ name = $ this ->getName ();
30
- $ path = $ this ->getPath ();
31
-
32
- $ this ->create ($ path . '/ ' . $ name );
32
+ return 'Operation [ ' . $ this ->displayName ($ path ) . '] created successfully ' ;
33
33
}
34
34
35
35
protected function create (string $ path ): void
36
36
{
37
37
File::copy ($ this ->stubPath (), $ path );
38
38
}
39
39
40
- protected function getName ( ): string
40
+ protected function displayName ( string $ path ): string
41
41
{
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
+ }
43
48
44
- return $ this ->getFilename ($ branch );
49
+ protected function getName (): string
50
+ {
51
+ return $ this ->getFilename (
52
+ $ this ->getBranchName ()
53
+ );
45
54
}
46
55
47
56
protected function getPath (): string
48
57
{
49
58
return $ this ->options ->path ;
50
59
}
51
60
61
+ protected function getFullPath (): string
62
+ {
63
+ return $ this ->getPath () . $ this ->getName ();
64
+ }
65
+
52
66
protected function getFilename (string $ branch ): string
53
67
{
54
68
$ directory = Path::dirname ($ branch );
@@ -59,6 +73,8 @@ protected function getFilename(string $branch): string
59
73
->prepend ($ this ->getTime ())
60
74
->finish ('.php ' )
61
75
->prepend ($ directory . '/ ' )
76
+ ->replace ('\\' , '/ ' )
77
+ ->ltrim ('./ ' )
62
78
->toString ();
63
79
}
64
80
@@ -100,4 +116,9 @@ protected function stubPath(): string
100
116
101
117
return $ this ->defaultStub ;
102
118
}
119
+
120
+ protected function showFullPath (): bool
121
+ {
122
+ return $ this ->config ->showFullPath ();
123
+ }
103
124
}
0 commit comments