Skip to content
This repository was archived by the owner on Jan 7, 2025. It is now read-only.

Commit 5f4a838

Browse files
Apply fixes from StyleCI (#46)
1 parent 06ba6a7 commit 5f4a838

File tree

4 files changed

+65
-65
lines changed

4 files changed

+65
-65
lines changed

src/Rules/EfficientUuidExists.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22

33
namespace Dyrynda\Database\Rules;
44

5-
use Ramsey\Uuid\Uuid;
65
use Illuminate\Contracts\Validation\Rule;
6+
use Ramsey\Uuid\Uuid;
77

88
class EfficientUuidExists implements Rule
99
{
10-
/** @var \Dyrynda\Database\GeneratesUuid */
11-
protected $model;
10+
/** @var \Dyrynda\Database\GeneratesUuid */
11+
protected $model;
1212

13-
/** @var string */
14-
protected $column;
13+
/** @var string */
14+
protected $column;
1515

16-
public function __construct(string $model, string $column = 'uuid')
17-
{
18-
$this->model = new $model;
16+
public function __construct(string $model, string $column = 'uuid')
17+
{
18+
$this->model = new $model;
1919

20-
$this->column = $column;
21-
}
20+
$this->column = $column;
21+
}
2222

23-
public function passes($attribute, $value): bool
24-
{
25-
if (Uuid::isValid($value)) {
26-
$binaryUuid = Uuid::fromString(strtolower($value))->getBytes();
23+
public function passes($attribute, $value): bool
24+
{
25+
if (Uuid::isValid($value)) {
26+
$binaryUuid = Uuid::fromString(strtolower($value))->getBytes();
2727

28-
return $this->model->where($this->column, $binaryUuid)->exists();
29-
}
28+
return $this->model->where($this->column, $binaryUuid)->exists();
29+
}
3030

31-
return false;
32-
}
31+
return false;
32+
}
3333

34-
public function message(): string
35-
{
36-
return trans('validation.exists');
37-
}
34+
public function message(): string
35+
{
36+
return trans('validation.exists');
37+
}
3838
}

tests/EfficientUuidExistsRuleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ class EfficientUuidExistsRuleTest extends TestCase
1111
/** @test */
1212
public function it_passes_valid_existing_uuid()
1313
{
14-
/** @var \Tests\Fixtures\EfficientUuidPost $post */
14+
/** @var \Tests\Fixtures\EfficientUuidPost $post */
1515
$post = factory(EfficientUuidPost::class)->create();
1616

1717
$rule = new EfficientUuidExists(EfficientUuidPost::class);
@@ -32,7 +32,7 @@ public function it_fails_on_non_existing_uuid()
3232
/** @test */
3333
public function it_fails_on_any_non_uuid_invalid_strings()
3434
{
35-
$uuid = "1235123564354633";
35+
$uuid = '1235123564354633';
3636

3737
$rule = new EfficientUuidExists(EfficientUuidPost::class, 'uuid');
3838

@@ -42,7 +42,7 @@ public function it_fails_on_any_non_uuid_invalid_strings()
4242
/** @test */
4343
public function it_works_with_custom_uuid_column_name()
4444
{
45-
/** @var \Tests\Fixtures\EfficientUuidPost $post */
45+
/** @var \Tests\Fixtures\EfficientUuidPost $post */
4646
$post = factory(EfficientUuidPost::class)->create();
4747

4848
$rule = new EfficientUuidExists(EfficientUuidPost::class, 'custom_uuid');

tests/Fixtures/EfficientUuidPost.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,27 +2,27 @@
22

33
namespace Tests\Fixtures;
44

5-
use Illuminate\Database\Eloquent\Model;
65
use Dyrynda\Database\Casts\EfficientUuid;
76
use Dyrynda\Database\Support\GeneratesUuid;
7+
use Illuminate\Database\Eloquent\Model;
88

99
class EfficientUuidPost extends Model
1010
{
11-
use GeneratesUuid;
11+
use GeneratesUuid;
1212

13-
protected $table = 'posts';
13+
protected $table = 'posts';
1414

15-
public $timestamps = false;
15+
public $timestamps = false;
1616

17-
protected $casts = [
18-
'uuid' => EfficientUuid::class,
17+
protected $casts = [
18+
'uuid' => EfficientUuid::class,
1919
'custom_uuid' => EfficientUuid::class,
20-
];
20+
];
2121

22-
public function uuidColumn(): string
23-
{
24-
return 'uuid';
25-
}
22+
public function uuidColumn(): string
23+
{
24+
return 'uuid';
25+
}
2626

2727
public function uuidColumns(): array
2828
{

tests/TestCase.php

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -2,37 +2,37 @@
22

33
namespace Tests;
44

5-
use Illuminate\Support\Facades\Schema;
6-
use Illuminate\Database\Schema\Blueprint;
75
use Dyrynda\Database\LaravelEfficientUuidServiceProvider;
6+
use Illuminate\Database\Schema\Blueprint;
7+
use Illuminate\Support\Facades\Schema;
88

99
class TestCase extends \Orchestra\Testbench\TestCase
1010
{
11-
protected function setUp(): void
12-
{
13-
parent::setUp();
14-
15-
$this->withFactories(realpath(__DIR__ . '/database/factories'));
16-
17-
$this->setupDatabase($this->app);
18-
}
19-
20-
protected function getPackageProviders($app)
21-
{
22-
return [
23-
LaravelEfficientUuidServiceProvider::class,
24-
];
25-
}
26-
27-
protected function setupDatabase($app)
28-
{
29-
Schema::dropAllTables();
30-
31-
$app['db']->connection()->getSchemaBuilder()->create('posts', function (Blueprint $table) {
32-
$table->increments('id');
33-
$table->efficientUuid('uuid');
34-
$table->efficientUuid('custom_uuid');
35-
$table->string('title');
36-
});
37-
}
11+
protected function setUp(): void
12+
{
13+
parent::setUp();
14+
15+
$this->withFactories(realpath(__DIR__.'/database/factories'));
16+
17+
$this->setupDatabase($this->app);
18+
}
19+
20+
protected function getPackageProviders($app)
21+
{
22+
return [
23+
LaravelEfficientUuidServiceProvider::class,
24+
];
25+
}
26+
27+
protected function setupDatabase($app)
28+
{
29+
Schema::dropAllTables();
30+
31+
$app['db']->connection()->getSchemaBuilder()->create('posts', function (Blueprint $table) {
32+
$table->increments('id');
33+
$table->efficientUuid('uuid');
34+
$table->efficientUuid('custom_uuid');
35+
$table->string('title');
36+
});
37+
}
3838
}

0 commit comments

Comments
 (0)