From 445bc6dda4672506b1e8060fa3e6c129f525954d Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 15 Nov 2022 13:41:18 +0800 Subject: [PATCH 1/2] fix(phpstan): fix phpstan and duplicate codes --- src/Generators/DataTablesMakeCommand.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Generators/DataTablesMakeCommand.php b/src/Generators/DataTablesMakeCommand.php index a0ae5bb..2a4c2d8 100644 --- a/src/Generators/DataTablesMakeCommand.php +++ b/src/Generators/DataTablesMakeCommand.php @@ -48,7 +48,7 @@ public function handle() $dom = config('datatables-buttons.generator.dom', 'Bfrtip'); $this->call('datatables:html', [ - 'name' => $this->prepareHtmlBuilderName($this->getNameInput()), + 'name' => $this->getDataTableBaseName(), '--columns' => $this->option('columns') ?: $columns, '--buttons' => $this->option('buttons') ?: $buttons, '--dom' => $this->option('dom') ?: $dom, @@ -65,7 +65,7 @@ public function handle() * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ - protected function buildClass($name) + protected function buildClass($name): string { $stub = parent::buildClass($name); @@ -83,13 +83,13 @@ protected function buildClass($name) } /** - * Prepare html builder name from input. + * Get DataTable class base name without the suffix. * * @return string */ - protected function prepareHtmlBuilderName(): string + protected function getDataTableBaseName(): string { - return preg_replace('#datatable$#i', '', $this->getNameInput()); + return (string) preg_replace('#datatable$#i', '', $this->getNameInput()); } /** @@ -99,7 +99,7 @@ protected function prepareHtmlBuilderName(): string */ protected function prepareModelName(): string { - return basename(preg_replace('#datatable$#i', '', $this->getNameInput())); + return basename($this->getDataTableBaseName()); } /** From 075e24c7f682f62c92eb11e9a7c398916482513a Mon Sep 17 00:00:00 2001 From: Arjay Angeles Date: Tue, 15 Nov 2022 13:50:53 +0800 Subject: [PATCH 2/2] fix: buildClass declaration --- src/Generators/DataTablesHtmlCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Generators/DataTablesHtmlCommand.php b/src/Generators/DataTablesHtmlCommand.php index 983cf57..5406ca0 100644 --- a/src/Generators/DataTablesHtmlCommand.php +++ b/src/Generators/DataTablesHtmlCommand.php @@ -41,7 +41,7 @@ class DataTablesHtmlCommand extends DataTablesMakeCommand * * @throws \Illuminate\Contracts\Filesystem\FileNotFoundException */ - protected function buildClass($name) + protected function buildClass($name): string { $stub = $this->files->get($this->getStub());