Skip to content

Commit 050d900

Browse files
nezaboravigithub-actions[bot]
authored andcommitted
Fix styling
1 parent 2b970e0 commit 050d900

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

src/SlugGenerator.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -33,31 +33,31 @@ public function generateUniqueSlug(string $slug): string
3333

3434
$existingSlugs = $this->getExistingSlugs($slug, $this->getTable());
3535

36-
if (!in_array($slug, $existingSlugs)) {
37-
return $slug . ($slugNumber ? "-$slugNumber" : '');
36+
if (! in_array($slug, $existingSlugs)) {
37+
return $slug.($slugNumber ? "-$slugNumber" : '');
3838
}
3939

4040
$i = $slugNumber ? ($slugNumber + 1) : 1;
4141
$uniqueSlugFound = false;
4242

4343
// Antoni will like this one :D
44-
while (!$uniqueSlugFound) {
45-
$newSlug = $slug . '-' . $i;
44+
while (! $uniqueSlugFound) {
45+
$newSlug = $slug.'-'.$i;
4646

47-
if (!in_array($newSlug, $existingSlugs)) {
47+
if (! in_array($newSlug, $existingSlugs)) {
4848
// Unique slug found
4949
return $newSlug;
5050
}
5151

5252
$i++;
5353
}
5454

55-
return $originalSlug . '-' . mt_rand(1000, 9999);
55+
return $originalSlug.'-'.mt_rand(1000, 9999);
5656
}
5757

5858
private function getExistingSlugs(string $slug, string $table): array
5959
{
60-
return $this->where('slug', 'LIKE', $slug . '%')
60+
return $this->where('slug', 'LIKE', $slug.'%')
6161
->where('id', '!=', $this->id ?? null)
6262
->pluck('slug')
6363
->toArray();

tests/SlugGeneratorTest.php

+5-3
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
namespace CodingWisely\SlugGenerator\Tests;
44

55
use CodingWisely\SlugGenerator\SlugGenerator;
6-
use Illuminate\Support\Facades\Schema;
76
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Support\Facades\Schema;
88
use Illuminate\Support\Str;
99
use Orchestra\Testbench\TestCase;
1010

1111
// Assumes SlugGenerator is a trait and not a Laravel Facade
1212

13-
1413
class SlugGeneratorTest extends TestCase
1514
{
1615
/** @test */
@@ -46,11 +45,14 @@ protected function getEnvironmentSetUp($app)
4645
});
4746
}
4847
}
49-
class TestModel extends \Illuminate\Database\Eloquent\Model {
48+
class TestModel extends \Illuminate\Database\Eloquent\Model
49+
{
5050
use SlugGenerator;
5151

5252
protected $table = 'test_models';
53+
5354
protected $guarded = [];
55+
5456
public $timestamps = false;
5557

5658
public static function getSluggableField()

tests/TestCase.php

-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
namespace CodingWisely\SlugGenerator\Tests;
44

55
use CodingWisely\SlugGenerator\SlugGeneratorServiceProvider;
6-
use Illuminate\Database\Eloquent\Factories\Factory;
76
use Orchestra\Testbench\TestCase as Orchestra;
87

98
class TestCase extends Orchestra

0 commit comments

Comments
 (0)