diff --git a/composer.json b/composer.json index bd4b264..03a5c2b 100644 --- a/composer.json +++ b/composer.json @@ -52,8 +52,8 @@ ] }, "scripts-descriptions": { - "csfix": "Runs Pint to fix project files.", - "csfix-review": "Runs Pint to show the details of which files are out of code standard." + "csfix": "Runs Pint to fix code style.", + "csfix-review": "Runs Pint to show the code style review." }, "minimum-stability": "dev", "prefer-stable": true diff --git a/pint.json b/pint.json index c781933..58e569c 100644 --- a/pint.json +++ b/pint.json @@ -1,3 +1,3 @@ { - "preset": "psr12" + "preset": "per" } \ No newline at end of file diff --git a/readme.md b/readme.md index b119598..01758b1 100644 --- a/readme.md +++ b/readme.md @@ -131,7 +131,9 @@ This command will use the generated files from the `ibis-next build` command to ## Development -This project uses PHP CS Fixer with a code standard defined in `.php_cs`. +This project uses Laravel Pint to fix the code style according to `per` preset. +The `pint.json` file defines the Laravel Pint configuration. +Laravel Pint is built on top of the great tool PHP-CS-Fixer. To review code out of style, you can run the fix command as a dry run. Run the composer script like this: diff --git a/src/Commands/BuildCommand.php b/src/Commands/BuildCommand.php index f89bd5f..f60e29d 100644 --- a/src/Commands/BuildCommand.php +++ b/src/Commands/BuildCommand.php @@ -85,7 +85,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $theme = $this->getTheme($currentPath, $this->themeName); $this->buildPdf( - $this->buildHtml($currentPath.'/content', $config), + $this->buildHtml($currentPath . '/content', $config), $config, $currentPath, $theme @@ -104,9 +104,9 @@ protected function ensureExportDirectoryExists(string $currentPath): void { $this->output->writeln('==> Preparing Export Directory ...'); - if (!$this->disk->isDirectory($currentPath.'/export')) { + if (!$this->disk->isDirectory($currentPath . '/export')) { $this->disk->makeDirectory( - $currentPath.'/export', + $currentPath . '/export', 0755, true ); @@ -216,7 +216,7 @@ protected function buildPdf(Collection $chapters, array $config, string $current 'margin_right' => $config['document']['margin_right'] ?? 27, 'margin_bottom' => $config['document']['margin_bottom'] ?? 14, 'margin_top' => $config['document']['margin_top'] ?? 14, - 'fontDir' => array_merge($fontDirs, [getcwd().'/assets/fonts']), + 'fontDir' => array_merge($fontDirs, [getcwd() . '/assets/fonts']), 'fontdata' => $this->fonts($config, $fontData), ]); @@ -238,7 +238,7 @@ protected function buildPdf(Collection $chapters, array $config, string $current if (key_exists("image", $config['cover'])) { $coverImage = $config['cover']['image']; } - if ($this->disk->isFile($currentPath.'/assets/' . $coverImage)) { + if ($this->disk->isFile($currentPath . '/assets/' . $coverImage)) { $this->output->writeln('==> Adding Book Cover ...'); $coverPosition = $config['cover']['position'] ?? 'position: absolute; left:0; right: 0; top: -.2; bottom: 0;'; @@ -253,10 +253,10 @@ protected function buildPdf(Collection $chapters, array $config, string $current ); $pdf->AddPage(); - } elseif ($this->disk->isFile($currentPath.'/assets/cover.html')) { + } elseif ($this->disk->isFile($currentPath . '/assets/cover.html')) { $this->output->writeln('==> Adding Book Cover ...'); - $cover = $this->disk->get($currentPath.'/assets/cover.html'); + $cover = $this->disk->get($currentPath . '/assets/cover.html'); $pdf->WriteHTML($cover); @@ -274,7 +274,7 @@ protected function buildPdf(Collection $chapters, array $config, string $current ); foreach ($chapters as $key => $chapter) { - $this->output->writeln('==> ❇️ '.$chapter["mdfile"].' ...'); + $this->output->writeln('==> ❇️ ' . $chapter["mdfile"] . ' ...'); if (array_key_exists('header', $config)) { $pdf->SetHTMLHeader( ' @@ -291,10 +291,10 @@ protected function buildPdf(Collection $chapters, array $config, string $current $this->output->writeln('==> Writing PDF To Disk ...'); $this->output->writeln(''); - $this->output->writeln('✨✨ '.$pdf->page.' PDF pages ✨✨'); + $this->output->writeln('✨✨ ' . $pdf->page . ' PDF pages ✨✨'); $pdf->Output( - $currentPath.'/export/'.Ibis::outputFileName().'-'.$this->themeName.'.pdf' + $currentPath . '/export/' . Ibis::outputFileName() . '-' . $this->themeName . '.pdf' ); } @@ -306,7 +306,7 @@ protected function buildPdf(Collection $chapters, array $config, string $current */ private function getTheme($currentPath, $themeName) { - return $this->disk->get($currentPath."/assets/theme-$themeName.html"); + return $this->disk->get($currentPath . "/assets/theme-$themeName.html"); } /** diff --git a/src/Commands/InitCommand.php b/src/Commands/InitCommand.php index ce252af..5b1e293 100644 --- a/src/Commands/InitCommand.php +++ b/src/Commands/InitCommand.php @@ -47,7 +47,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $currentPath = getcwd(); - if ($this->disk->isDirectory($currentPath.'/assets')) { + if ($this->disk->isDirectory($currentPath . '/assets')) { $this->output->writeln(''); $this->output->writeln('Project already initialised!'); @@ -55,40 +55,40 @@ public function execute(InputInterface $input, OutputInterface $output): int } $this->disk->makeDirectory( - $currentPath.'/assets' + $currentPath . '/assets' ); $this->disk->makeDirectory( - $currentPath.'/assets/fonts' + $currentPath . '/assets/fonts' ); $this->disk->makeDirectory( - $currentPath.'/content' + $currentPath . '/content' ); $this->disk->copyDirectory( - __DIR__.'/../../stubs/content', - $currentPath.'/content' + __DIR__ . '/../../stubs/content', + $currentPath . '/content' ); $this->disk->put( - $currentPath.'/ibis.php', - $this->disk->get(__DIR__.'/../../stubs/ibis.php') + $currentPath . '/ibis.php', + $this->disk->get(__DIR__ . '/../../stubs/ibis.php') ); $this->disk->put( - $currentPath.'/assets/cover.jpg', - $this->disk->get(__DIR__.'/../../stubs/assets/cover.jpg') + $currentPath . '/assets/cover.jpg', + $this->disk->get(__DIR__ . '/../../stubs/assets/cover.jpg') ); $this->disk->put( - $currentPath.'/assets/theme-dark.html', - $this->disk->get(__DIR__.'/../../stubs/assets/theme-dark.html') + $currentPath . '/assets/theme-dark.html', + $this->disk->get(__DIR__ . '/../../stubs/assets/theme-dark.html') ); $this->disk->put( - $currentPath.'/assets/theme-light.html', - $this->disk->get(__DIR__.'/../../stubs/assets/theme-light.html') + $currentPath . '/assets/theme-light.html', + $this->disk->get(__DIR__ . '/../../stubs/assets/theme-light.html') ); $this->output->writeln(''); diff --git a/src/Commands/SampleCommand.php b/src/Commands/SampleCommand.php index fbbc08d..9ae4783 100644 --- a/src/Commands/SampleCommand.php +++ b/src/Commands/SampleCommand.php @@ -49,13 +49,13 @@ public function execute(InputInterface $input, OutputInterface $output): int $currentPath = getcwd(); - $config = require $currentPath.'/ibis.php'; + $config = require $currentPath . '/ibis.php'; $mpdf = new \Mpdf\Mpdf(); - $fileName = Ibis::outputFileName().'-'.$input->getArgument('theme'); + $fileName = Ibis::outputFileName() . '-' . $input->getArgument('theme'); - $mpdf->setSourceFile($currentPath.'/export/'.$fileName.'.pdf'); + $mpdf->setSourceFile($currentPath . '/export/' . $fileName . '.pdf'); foreach ($config['sample'] as $range) { foreach (range($range[0], $range[1]) as $page) { @@ -66,10 +66,10 @@ public function execute(InputInterface $input, OutputInterface $output): int } } - $mpdf->WriteHTML('

'.$config['sample_notice'].'

'); + $mpdf->WriteHTML('

' . $config['sample_notice'] . '

'); $mpdf->Output( - $currentPath.'/export/sample-.'.$fileName.'.pdf' + $currentPath . '/export/sample-.' . $fileName . '.pdf' ); return 0; diff --git a/src/Commands/SortContentCommand.php b/src/Commands/SortContentCommand.php index c273e12..a07b0c5 100644 --- a/src/Commands/SortContentCommand.php +++ b/src/Commands/SortContentCommand.php @@ -47,7 +47,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $currentPath = getcwd(); - collect($this->disk->files($currentPath.'/content'))->each(function ($file, $index) use ($currentPath) { + collect($this->disk->files($currentPath . '/content'))->each(function ($file, $index) use ($currentPath) { $markdown = $this->disk->get( $file->getPathname() ); @@ -60,7 +60,7 @@ public function execute(InputInterface $input, OutputInterface $output): int $this->disk->move( $file->getPathName(), - $currentPath.'/content/'.Str::slug($newName).'.md' + $currentPath . '/content/' . Str::slug($newName) . '.md' ); }); diff --git a/src/Ibis.php b/src/Ibis.php index fd2c917..c3e153f 100644 --- a/src/Ibis.php +++ b/src/Ibis.php @@ -44,7 +44,7 @@ private static function config() return static::$config; } - static::$config = require getcwd().'/ibis.php'; + static::$config = require getcwd() . '/ibis.php'; return static::$config; }