Skip to content

Commit bf17b47

Browse files
committed
refactor: clean up code style using pint
1 parent 20ec7f2 commit bf17b47

File tree

11 files changed

+60
-67
lines changed

11 files changed

+60
-67
lines changed

contexts/Authorization/Application/Coordinators/RoleCoordinator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ class RoleCoordinator extends BaseCoordinator
2121
public function __construct(
2222
private RoleRepository $repository,
2323
private RoleFactory $factory
24-
) {
25-
}
24+
) {}
2625

2726
public function create(CreateRoleDTO $data): Role
2827
{

contexts/Authorization/Application/Coordinators/UserIdentityCoordinator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ class UserIdentityCoordinator extends BaseCoordinator
2525
public function __construct(
2626
private UserRepository $repository,
2727
private UserIdentityFactory $factory
28-
) {
29-
}
28+
) {}
3029

3130
public function create(CreateUserDTO $data): UserIdentity
3231
{

contexts/Authorization/Domain/Factories/RoleFactory.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ class RoleFactory
1515
{
1616
public function __construct(
1717
private readonly RoleLabelUniquenessService $roleLabelUniquenessService
18-
) {
19-
}
18+
) {}
2019

2120
public function create(
2221
RoleId $id,

contexts/Authorization/Domain/Factories/UserIdentityFactory.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44

55
namespace Contexts\Authorization\Domain\Factories;
66

7+
use Carbon\CarbonImmutable;
78
use Contexts\Authorization\Domain\Services\UserEmailUniquenessService;
8-
use Contexts\Authorization\Domain\UserIdentity\Models\UserIdentity;
9-
use Contexts\Authorization\Domain\UserIdentity\Models\UserId;
9+
use Contexts\Authorization\Domain\UserIdentity\Events\UserCreatedEvent;
1010
use Contexts\Authorization\Domain\UserIdentity\Models\Email;
1111
use Contexts\Authorization\Domain\UserIdentity\Models\Password;
12-
use Carbon\CarbonImmutable;
12+
use Contexts\Authorization\Domain\UserIdentity\Models\UserId;
13+
use Contexts\Authorization\Domain\UserIdentity\Models\UserIdentity;
1314
use Contexts\Authorization\Domain\UserIdentity\Models\UserStatus;
14-
use Contexts\Authorization\Domain\UserIdentity\Events\UserCreatedEvent;
1515

1616
class UserIdentityFactory
1717
{
1818
public function __construct(
1919
private readonly UserEmailUniquenessService $userEmailUniquenessService
20-
) {
21-
}
20+
) {}
2221

2322
public function create(
2423
UserId $id,

contexts/Authorization/Domain/Services/UserEmailUniquenessService.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ class UserEmailUniquenessService
1111
{
1212
public function __construct(
1313
private readonly UserRepository $userRepository
14-
) {
15-
}
14+
) {}
1615

1716
public function ensureUnique(string $email)
1817
{

contexts/Authorization/Domain/UserIdentity/Models/UserIdentity.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ private function __construct(
2626
private ?CarbonImmutable $updated_at = null
2727
) {
2828
$this->created_at = $created_at ?? CarbonImmutable::now();
29-
$this->roleIdCollection = new RoleIdCollection();
29+
$this->roleIdCollection = new RoleIdCollection;
3030
}
3131

3232
public function hasAnyRole(RoleIdCollection $roleIds): bool
@@ -106,7 +106,7 @@ public static function reconstitute(
106106
array $events = []
107107
): self {
108108
$user = new self($id, $email, $password, $display_name, $status, $created_at, $updated_at);
109-
$user->roleIdCollection = $roleIdCollection ?? new RoleIdCollection();
109+
$user->roleIdCollection = $roleIdCollection ?? new RoleIdCollection;
110110

111111
foreach ($events as $event) {
112112
$user->recordEvent($event);

contexts/Authorization/Tests/Feature/Application/GlobalPermissionServiceCoordinatorTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,16 +4,16 @@
44

55
use Contexts\Authorization\Application\Coordinators\GlobalPermissionServiceCoordinator;
66
use Contexts\Authorization\Contracts\V1\Services\GlobalPermissionService;
7+
use Contexts\Authorization\Domain\Factories\RoleFactory;
78
use Contexts\Authorization\Domain\Policies\RolePolicy;
89
use Contexts\Authorization\Domain\Role\Models\Role;
910
use Contexts\Authorization\Domain\Role\Models\RoleId;
11+
use Contexts\Authorization\Domain\Services\RoleLabelUniquenessService;
1012
use Contexts\Authorization\Domain\UserIdentity\Models\RoleIdCollection;
1113
use Contexts\Authorization\Infrastructure\Persistence\RolePersistence;
1214
use Contexts\Authorization\Infrastructure\Persistence\UserPersistence;
1315
use Contexts\Authorization\Infrastructure\Records\UserRecord;
1416
use Illuminate\Support\Facades\Config;
15-
use Contexts\Authorization\Domain\Services\RoleLabelUniquenessService;
16-
use Contexts\Authorization\Domain\Factories\RoleFactory;
1717

1818
beforeEach(function () {
1919
Config::set('policies.article_publishing', [
@@ -53,8 +53,8 @@
5353

5454
it('can check permission for admin user', function () {
5555
// Setup repositories
56-
$userPersistence = new UserPersistence();
57-
$rolePersistence = new RolePersistence();
56+
$userPersistence = new UserPersistence;
57+
$rolePersistence = new RolePersistence;
5858

5959
// Create admin user
6060
$userRecord = UserRecord::factory()->create();
@@ -76,8 +76,8 @@
7676

7777
it('denies permission for users without required roles', function () {
7878
// Setup repositories
79-
$userPersistence = new UserPersistence();
80-
$rolePersistence = new RolePersistence();
79+
$userPersistence = new UserPersistence;
80+
$rolePersistence = new RolePersistence;
8181

8282
// Create regular user
8383
$userRecord = UserRecord::factory()->create();

contexts/Authorization/Tests/Feature/Infrastructure/Persistence/RolePersistenceTest.php

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

33
declare(strict_types=1);
44
use Carbon\CarbonImmutable;
5+
use Contexts\Authorization\Domain\Factories\RoleFactory;
56
use Contexts\Authorization\Domain\Role\Exceptions\RoleNotFoundException;
67
use Contexts\Authorization\Domain\Role\Models\Role;
78
use Contexts\Authorization\Domain\Role\Models\RoleId;
89
use Contexts\Authorization\Domain\Role\Models\RoleStatus;
10+
use Contexts\Authorization\Domain\Services\RoleLabelUniquenessService;
911
use Contexts\Authorization\Infrastructure\Persistence\RolePersistence;
1012
use Contexts\Authorization\Infrastructure\Records\RoleRecord;
11-
use Contexts\Authorization\Domain\Factories\RoleFactory;
12-
use Contexts\Authorization\Domain\Services\RoleLabelUniquenessService;
1313

1414
beforeEach(function () {
1515
$this->roleLabelUniquenessService = mock(RoleLabelUniquenessService::class);
@@ -19,7 +19,7 @@
1919

2020
it('can persist role data correctly', function () {
2121
$role = $this->roleFactory->create(RoleId::null(), 'My Role');
22-
$rolePersistence = new RolePersistence();
22+
$rolePersistence = new RolePersistence;
2323

2424
$rolePersistence->create($role);
2525

@@ -32,7 +32,7 @@
3232
it('can retrieve an role by ID', function () {
3333
// Create a test role in the database
3434
$createdRole = $this->roleFactory->create(RoleId::null(), 'Test Role');
35-
$rolePersistence = new RolePersistence();
35+
$rolePersistence = new RolePersistence;
3636
$savedRole = $rolePersistence->create($createdRole);
3737

3838
// Retrieve the role using getById
@@ -46,7 +46,7 @@
4646

4747
it('can retrieve multiple roles by IDs', function () {
4848
// Create multiple test roles in the database
49-
$rolePersistence = new RolePersistence();
49+
$rolePersistence = new RolePersistence;
5050

5151
$role1 = $this->roleFactory->create(RoleId::null(), 'Role 1');
5252
$role2 = $this->roleFactory->create(RoleId::null(), 'Role 2');
@@ -71,7 +71,7 @@
7171
});
7272

7373
it('throws an exception when retrieving a non-existent role', function () {
74-
$rolePersistence = new RolePersistence();
74+
$rolePersistence = new RolePersistence;
7575

7676
// Attempt to retrieve a non-existent role
7777
$rolePersistence->getById(RoleId::fromInt(999));
@@ -80,7 +80,7 @@
8080
it('can update an role', function () {
8181
// Create a test role in the database
8282
$createdRole = $this->roleFactory->create(RoleId::null(), 'Original Label');
83-
$rolePersistence = new RolePersistence();
83+
$rolePersistence = new RolePersistence;
8484
$savedRole = $rolePersistence->create($createdRole);
8585

8686
// Create an updated version of the role
@@ -105,22 +105,22 @@
105105
});
106106

107107
it('throws an exception when updating a non-existent role', function () {
108-
$rolePersistence = new RolePersistence();
108+
$rolePersistence = new RolePersistence;
109109

110110
// Attempt to update a non-existent role
111111
$rolePersistence->update($this->roleFactory->create(RoleId::fromInt(999), 'Updated Label'));
112112
})->throws(RoleNotFoundException::class);
113113

114114
it('can paginate roles', function () {
115115
// Create multiple test roles
116-
$rolePersistence = new RolePersistence();
116+
$rolePersistence = new RolePersistence;
117117

118118
// Create 5 roles
119119
for ($i = 1; $i <= 5; $i++) {
120120
$role = $this->roleFactory->create(
121121
RoleId::null(),
122122
"Role $i",
123-
new CarbonImmutable()
123+
new CarbonImmutable
124124
);
125125
$rolePersistence->create($role);
126126
}
@@ -146,28 +146,28 @@
146146
});
147147

148148
it('can filter roles with search criteria', function () {
149-
$rolePersistence = new RolePersistence();
149+
$rolePersistence = new RolePersistence;
150150

151151
// Create roles with specific labels
152152
$role1 = $this->roleFactory->create(
153153
RoleId::null(),
154154
'Laravel Role',
155-
new CarbonImmutable()
155+
new CarbonImmutable
156156
);
157157
$rolePersistence->create($role1);
158158

159159
$role2 = $this->roleFactory->create(
160160
RoleId::null(),
161161
'PHP Tutorial',
162-
new CarbonImmutable()
162+
new CarbonImmutable
163163
);
164164
$role2->subspend();
165165
$rolePersistence->create($role2);
166166

167167
$role3 = $this->roleFactory->create(
168168
RoleId::null(),
169169
'Laravel Tips',
170-
new CarbonImmutable()
170+
new CarbonImmutable
171171
);
172172
$role3->subspend();
173173
$rolePersistence->create($role3);
@@ -205,7 +205,7 @@
205205
it('can delete an role', function () {
206206
// Create a test role in the database
207207
$createdRole = $this->roleFactory->create(RoleId::null(), 'Test Role');
208-
$rolePersistence = new RolePersistence();
208+
$rolePersistence = new RolePersistence;
209209
$savedRole = $rolePersistence->create($createdRole);
210210

211211
// Delete the role
@@ -218,17 +218,16 @@
218218
});
219219

220220
it('throws an exception when deleting a non-existent role', function () {
221-
$rolePersistence = new RolePersistence();
221+
$rolePersistence = new RolePersistence;
222222

223223
// Attempt to delete a non-existent role
224224
$rolePersistence->delete($this->roleFactory->create(RoleId::fromInt(999), 'Test Role'));
225225
})->throws(RoleNotFoundException::class);
226226

227-
228227
it('returns true when role exists with given label', function () {
229228
// Create a test role in the database with a specific label
230229
$createdRole = $this->roleFactory->create(RoleId::null(), 'Unique Label');
231-
$rolePersistence = new RolePersistence();
230+
$rolePersistence = new RolePersistence;
232231
$rolePersistence->create($createdRole);
233232

234233
// Check if the method correctly detects the existing label
@@ -238,7 +237,7 @@
238237
});
239238

240239
it('returns false when role does not exist with given label', function () {
241-
$rolePersistence = new RolePersistence();
240+
$rolePersistence = new RolePersistence;
242241

243242
// Test with a label that doesn't exist in the database
244243
$result = $rolePersistence->existsByLabel('Non-Existent Label');
@@ -248,7 +247,7 @@
248247

249248
it('can retrieve roles by labels', function () {
250249
// Create roles with specific labels
251-
$rolePersistence = new RolePersistence();
250+
$rolePersistence = new RolePersistence;
252251

253252
$role1 = $this->roleFactory->create(RoleId::null(), 'Admin Role');
254253
$role2 = $this->roleFactory->create(RoleId::null(), 'Editor Role');
@@ -270,7 +269,7 @@
270269
});
271270

272271
it('returns empty collection when no roles match the given labels', function () {
273-
$rolePersistence = new RolePersistence();
272+
$rolePersistence = new RolePersistence;
274273

275274
// Retrieve with non-existent labels
276275
$retrievedRoles = $rolePersistence->getByLabels(['Non-Existent Label']);

0 commit comments

Comments
 (0)