Skip to content

Commit 6332449

Browse files
authored
Merge pull request #166 from yajra/patch-stan
fix: phpstan and duplicate code
2 parents 07beb0f + 075e24c commit 6332449

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/Generators/DataTablesHtmlCommand.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ class DataTablesHtmlCommand extends DataTablesMakeCommand
4141
*
4242
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
4343
*/
44-
protected function buildClass($name)
44+
protected function buildClass($name): string
4545
{
4646
$stub = $this->files->get($this->getStub());
4747

src/Generators/DataTablesMakeCommand.php

+6-6
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public function handle()
4848
$dom = config('datatables-buttons.generator.dom', 'Bfrtip');
4949

5050
$this->call('datatables:html', [
51-
'name' => $this->prepareHtmlBuilderName($this->getNameInput()),
51+
'name' => $this->getDataTableBaseName(),
5252
'--columns' => $this->option('columns') ?: $columns,
5353
'--buttons' => $this->option('buttons') ?: $buttons,
5454
'--dom' => $this->option('dom') ?: $dom,
@@ -65,7 +65,7 @@ public function handle()
6565
*
6666
* @throws \Illuminate\Contracts\Filesystem\FileNotFoundException
6767
*/
68-
protected function buildClass($name)
68+
protected function buildClass($name): string
6969
{
7070
$stub = parent::buildClass($name);
7171

@@ -83,13 +83,13 @@ protected function buildClass($name)
8383
}
8484

8585
/**
86-
* Prepare html builder name from input.
86+
* Get DataTable class base name without the suffix.
8787
*
8888
* @return string
8989
*/
90-
protected function prepareHtmlBuilderName(): string
90+
protected function getDataTableBaseName(): string
9191
{
92-
return preg_replace('#datatable$#i', '', $this->getNameInput());
92+
return (string) preg_replace('#datatable$#i', '', $this->getNameInput());
9393
}
9494

9595
/**
@@ -99,7 +99,7 @@ protected function prepareHtmlBuilderName(): string
9999
*/
100100
protected function prepareModelName(): string
101101
{
102-
return basename(preg_replace('#datatable$#i', '', $this->getNameInput()));
102+
return basename($this->getDataTableBaseName());
103103
}
104104

105105
/**

0 commit comments

Comments
 (0)