diff --git a/src/Processors/Make.php b/src/Processors/Make.php index b0569998..e3c8e83d 100644 --- a/src/Processors/Make.php +++ b/src/Processors/Make.php @@ -7,6 +7,7 @@ use DragonCode\Support\Facades\Filesystem\File; use DragonCode\Support\Facades\Filesystem\Path; use DragonCode\Support\Facades\Helpers\Str; +use DragonCode\Support\Helpers\Ables\Stringable; use function base_path; use function date; @@ -21,14 +22,26 @@ class Make extends Processor public function handle(): void { - $pathWithName = $this->getPath().$this->getName(); + $this->notification->task($this->message(), fn () => $this->create()); + } - $this->notification->task('Creating an operation ['.$pathWithName.']', fn () => $this->create($pathWithName)); + protected function message(): string + { + return 'Operation [' . $this->displayName($this->getFullPath()) . '] created successfully'; } - protected function create(string $path): void + protected function create(): void { - File::copy($this->stubPath(), $path); + File::copy($this->stubPath(), $this->getFullPath()); + } + + protected function displayName(string $path): string + { + return Str::of($path) + ->when(! $this->showFullPath(), fn (Stringable $str) => $str->after(base_path())) + ->replace('\\', '/') + ->ltrim('./') + ->toString(); } protected function getName(): string @@ -43,6 +56,11 @@ protected function getPath(): string return $this->options->path; } + protected function getFullPath(): string + { + return $this->getPath() . $this->getName(); + } + protected function getFilename(string $branch): string { $directory = Path::dirname($branch); @@ -53,6 +71,7 @@ protected function getFilename(string $branch): string ->prepend($this->getTime()) ->finish('.php') ->prepend($directory . '/') + ->replace('\\', '/') ->ltrim('./') ->toString(); } @@ -95,4 +114,9 @@ protected function stubPath(): string return $this->defaultStub; } + + protected function showFullPath(): bool + { + return $this->config->showFullPath(); + } }