diff --git a/src/Blog.php b/src/Blog.php index 610ea91..9dda1fd 100644 --- a/src/Blog.php +++ b/src/Blog.php @@ -2,10 +2,10 @@ namespace Azzarip\NotaCMS; +use Illuminate\Database\Eloquent\Model; use Illuminate\Support\Arr; -use Illuminate\Support\Str; use Illuminate\Support\Facades\File; -use Illuminate\Database\Eloquent\Model; +use Illuminate\Support\Str; use RalphJSmit\Laravel\SEO\Support\HasSEO; use Spatie\YamlFrontMatter\YamlFrontMatter; @@ -38,8 +38,8 @@ public static function findSlug(string $slug): ?Blog public static function loadFile(string $fileName): ?Blog { - $path = self::getPath() . $fileName . '.md'; - if (!File::exists($path)) { + $path = self::getPath().$fileName.'.md'; + if (! File::exists($path)) { return null; } @@ -65,12 +65,12 @@ public static function loadFile(string $fileName): ?Blog private function getFilePath(): string { - return $this->getPath() . $this->slug . '.md'; + return $this->getPath().$this->slug.'.md'; } public static function getPath(): string { - return base_path('content/notacms/') . self::getRoute() . '/'; + return base_path('content/notacms/').self::getRoute().'/'; } public static function getRoute() diff --git a/src/Commands/Actions/CreateContent.php b/src/Commands/Actions/CreateContent.php index c77cafc..b5f383b 100644 --- a/src/Commands/Actions/CreateContent.php +++ b/src/Commands/Actions/CreateContent.php @@ -3,10 +3,11 @@ namespace Azzarip\NotaCMS\Commands\Actions; use Illuminate\Support\Facades\File; - -class CreateContent { - - public static function create(string $blog){ + +class CreateContent +{ + public static function create(string $blog) + { $contentPath = base_path('content/notacms'); if (! File::exists($contentPath)) { File::makeDirectory($contentPath, 0755, true); @@ -20,5 +21,5 @@ public static function create(string $blog){ $content = File::get(__DIR__.'/../../../stubs/post.stub'); File::put($contentPath.'/my-first-post.md', $content); } + } } -}; \ No newline at end of file diff --git a/src/Commands/LoadCommand.php b/src/Commands/LoadCommand.php index f6cbb5e..75b02df 100644 --- a/src/Commands/LoadCommand.php +++ b/src/Commands/LoadCommand.php @@ -2,8 +2,8 @@ namespace Azzarip\NotaCMS\Commands; -use Illuminate\Support\Arr; use Illuminate\Console\Command; +use Illuminate\Support\Arr; use Illuminate\Support\Facades\File; class LoadCommand extends Command @@ -19,26 +19,28 @@ public function handle(): int if (! $blog) { $blogs = array_keys(config('notacms')); - $blog = $this->choice("Which blog you want to load to database?", - Arr::prepend($blogs, 'all'), - $default='all'); + $blog = $this->choice('Which blog you want to load to database?', + Arr::prepend($blogs, 'all'), + $default = 'all'); } - if($blog === 'all') { + if ($blog === 'all') { foreach ($blogs as $blog) { $this->loadBlog($blog); - $this->comment('All files loaded for: ' . $blog); + $this->comment('All files loaded for: '.$blog); } + return self::SUCCESS; } $this->loadBlog($blog); + return self::SUCCESS; } private function loadBlog(string $blog): void { - $files = File::files(base_path('content/notacms/' . $blog)); + $files = File::files(base_path('content/notacms/'.$blog)); foreach ($files as $file) { if (pathinfo($file, PATHINFO_EXTENSION) === 'md') { $slug = pathinfo($file, PATHINFO_FILENAME); diff --git a/src/Commands/NewCommand.php b/src/Commands/NewCommand.php index 22634c1..2ac0985 100644 --- a/src/Commands/NewCommand.php +++ b/src/Commands/NewCommand.php @@ -2,10 +2,10 @@ namespace Azzarip\NotaCMS\Commands; -use Illuminate\Support\Str; +use Azzarip\NotaCMS\Commands\Actions\CreateContent; use Illuminate\Console\Command; use Illuminate\Support\Facades\File; -use Azzarip\NotaCMS\Commands\Actions\CreateContent; +use Illuminate\Support\Str; class NewCommand extends Command { diff --git a/src/NotaCMSServiceProvider.php b/src/NotaCMSServiceProvider.php index 33a62c3..378c6fa 100644 --- a/src/NotaCMSServiceProvider.php +++ b/src/NotaCMSServiceProvider.php @@ -4,7 +4,6 @@ use Azzarip\NotaCMS\Commands\LoadCommand; use Azzarip\NotaCMS\Commands\NewCommand; -use Illuminate\Support\Facades\File; use Spatie\LaravelPackageTools\Commands\InstallCommand; use Spatie\LaravelPackageTools\Package; use Spatie\LaravelPackageTools\PackageServiceProvider; diff --git a/tests/FileTest.php b/tests/FileTest.php index 13d9978..624771b 100644 --- a/tests/FileTest.php +++ b/tests/FileTest.php @@ -1,15 +1,16 @@