Skip to content

Commit 1a7d4db

Browse files
committed
refactor: clean up code style using pint
1 parent d94d32b commit 1a7d4db

File tree

8 files changed

+36
-44
lines changed

8 files changed

+36
-44
lines changed

contexts/ArticlePublishing/Application/Coordinators/ArticlePublishingCoordinator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class ArticlePublishingCoordinator extends BaseCoordinator
1919
{
2020
public function __construct(
2121
private ArticleRepository $repository
22-
) {
23-
}
22+
) {}
2423

2524
public function create(CreateArticleDTO $data): Article
2625
{

contexts/ArticlePublishing/Domain/Models/ArticleId.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
use Contexts\Shared\ValueObjects\IntId;
88

9-
class ArticleId extends IntId
10-
{
11-
}
9+
class ArticleId extends IntId {}

contexts/ArticlePublishing/Tests/Feature/Infrastructure/Repositories/ArticleRepositoryTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Contexts\ArticlePublishing\Infrastructure\Repositories\ArticleRepository;
1010

1111
it('can persist draft article data correctly', function () {
12-
$article = Article::createDraft(ArticleId::null(), 'My Article', 'This is my article body', new CarbonImmutable());
13-
$articleRepository = new ArticleRepository();
12+
$article = Article::createDraft(ArticleId::null(), 'My Article', 'This is my article body', new CarbonImmutable);
13+
$articleRepository = new ArticleRepository;
1414

1515
$articleRepository->create($article);
1616

@@ -22,8 +22,8 @@
2222
});
2323

2424
it('can persist published article data correctly', function () {
25-
$article = Article::createPublished(ArticleId::null(), 'My Article', 'This is my article body', new CarbonImmutable());
26-
$articleRepository = new ArticleRepository();
25+
$article = Article::createPublished(ArticleId::null(), 'My Article', 'This is my article body', new CarbonImmutable);
26+
$articleRepository = new ArticleRepository;
2727

2828
$articleRepository->create($article);
2929

@@ -36,8 +36,8 @@
3636

3737
it('can retrieve an article by ID', function () {
3838
// Create a test article in the database
39-
$createdArticle = Article::createDraft(ArticleId::null(), 'Test Article', 'Test Content', new CarbonImmutable());
40-
$articleRepository = new ArticleRepository();
39+
$createdArticle = Article::createDraft(ArticleId::null(), 'Test Article', 'Test Content', new CarbonImmutable);
40+
$articleRepository = new ArticleRepository;
4141
$savedArticle = $articleRepository->create($createdArticle);
4242

4343
// Retrieve the article using getById
@@ -52,16 +52,16 @@
5252

5353
it('can update an article', function () {
5454
// Create a test article in the database
55-
$createdArticle = Article::createDraft(ArticleId::null(), 'Original Title', 'Original Content', new CarbonImmutable());
56-
$articleRepository = new ArticleRepository();
55+
$createdArticle = Article::createDraft(ArticleId::null(), 'Original Title', 'Original Content', new CarbonImmutable);
56+
$articleRepository = new ArticleRepository;
5757
$savedArticle = $articleRepository->create($createdArticle);
5858

5959
// Create an updated version of the article
6060
$updatedArticle = Article::createPublished(
6161
$savedArticle->id,
6262
'Updated Title',
6363
'Updated Content',
64-
new CarbonImmutable()
64+
new CarbonImmutable
6565
);
6666

6767
// Update the article
@@ -83,15 +83,15 @@
8383

8484
it('can paginate articles', function () {
8585
// Create multiple test articles
86-
$articleRepository = new ArticleRepository();
86+
$articleRepository = new ArticleRepository;
8787

8888
// Create 5 articles
8989
for ($i = 1; $i <= 5; $i++) {
9090
$article = Article::createPublished(
9191
ArticleId::null(),
9292
"Article $i",
9393
"Content $i",
94-
new CarbonImmutable()
94+
new CarbonImmutable
9595
);
9696
$articleRepository->create($article);
9797
}
@@ -117,30 +117,30 @@
117117
});
118118

119119
it('can filter articles with search criteria', function () {
120-
$articleRepository = new ArticleRepository();
120+
$articleRepository = new ArticleRepository;
121121

122122
// Create articles with specific titles
123123
$article1 = Article::createDraft(
124124
ArticleId::null(),
125125
'Laravel Article',
126126
'Content about Laravel',
127-
new CarbonImmutable()
127+
new CarbonImmutable
128128
);
129129
$articleRepository->create($article1);
130130

131131
$article2 = Article::createDraft(
132132
ArticleId::null(),
133133
'PHP Tutorial',
134134
'Content about PHP',
135-
new CarbonImmutable()
135+
new CarbonImmutable
136136
);
137137
$articleRepository->create($article2);
138138

139139
$article3 = Article::createPublished(
140140
ArticleId::null(),
141141
'Laravel Tips',
142142
'More Laravel content',
143-
new CarbonImmutable()
143+
new CarbonImmutable
144144
);
145145
$articleRepository->create($article3);
146146

contexts/ArticlePublishing/Tests/Unit/Domain/Models/ArticleTest.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
use Contexts\ArticlePublishing\Domain\Models\ArticleStatus;
99

1010
it('can create draft article with valid data', function () {
11-
$article = Article::createDraft(ArticleId::null(), 'Title', 'body', new CarbonImmutable());
11+
$article = Article::createDraft(ArticleId::null(), 'Title', 'body', new CarbonImmutable);
1212
expect($article->getTitle())->toBe('Title');
1313
expect($article->getbody())->toBe('body');
1414
expect($article->getStatus()->equals(ArticleStatus::draft()))->toBeTrue();
1515
});
1616

1717
it('can create published article with valid data', function () {
18-
$article = Article::createPublished(ArticleId::null(), 'Title', 'body', new CarbonImmutable());
18+
$article = Article::createPublished(ArticleId::null(), 'Title', 'body', new CarbonImmutable);
1919
expect($article->getTitle())->toBe('Title');
2020
expect($article->getbody())->toBe('body');
2121
expect($article->getStatus()->equals(ArticleStatus::published()))->toBeTrue();
2222
});
2323

2424
it('can auto generate created_at date', function () {
25-
$article = Article::createDraft(ArticleId::null(), 'Title', 'body', new CarbonImmutable());
25+
$article = Article::createDraft(ArticleId::null(), 'Title', 'body', new CarbonImmutable);
2626
expect($article->getCreatedAt())->toBeInstanceOf(CarbonImmutable::class);
2727
});
2828

contexts/CategoryManagement/Application/Coordinators/CategoryManagementCoordinator.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ class CategoryManagementCoordinator extends BaseCoordinator
1919
{
2020
public function __construct(
2121
private CategoryRepository $repository
22-
) {
23-
}
22+
) {}
2423

2524
public function create(CreateCategoryDTO $data): Category
2625
{

contexts/CategoryManagement/Domain/Models/CategoryId.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@
66

77
use Contexts\Shared\ValueObjects\IntId;
88

9-
class CategoryId extends IntId
10-
{
11-
}
9+
class CategoryId extends IntId {}

contexts/CategoryManagement/Tests/Feature/Infrastructure/Repositories/CategoryRepositoryTest.php

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
it('can persist category data correctly', function () {
1212
$category = Category::create(CategoryId::null(), 'My Category');
13-
$categoryRepository = new CategoryRepository();
13+
$categoryRepository = new CategoryRepository;
1414

1515
$categoryRepository->create($category);
1616

@@ -23,7 +23,7 @@
2323
it('can retrieve an category by ID', function () {
2424
// Create a test category in the database
2525
$createdCategory = Category::create(CategoryId::null(), 'Test Category');
26-
$categoryRepository = new CategoryRepository();
26+
$categoryRepository = new CategoryRepository;
2727
$savedCategory = $categoryRepository->create($createdCategory);
2828

2929
// Retrieve the category using getById
@@ -38,7 +38,7 @@
3838
it('can update an category', function () {
3939
// Create a test category in the database
4040
$createdCategory = Category::create(CategoryId::null(), 'Original Label');
41-
$categoryRepository = new CategoryRepository();
41+
$categoryRepository = new CategoryRepository;
4242
$savedCategory = $categoryRepository->create($createdCategory);
4343

4444
// Create an updated version of the category
@@ -64,14 +64,14 @@
6464

6565
it('can paginate categories', function () {
6666
// Create multiple test categories
67-
$categoryRepository = new CategoryRepository();
67+
$categoryRepository = new CategoryRepository;
6868

6969
// Create 5 categories
7070
for ($i = 1; $i <= 5; $i++) {
7171
$category = Category::create(
7272
CategoryId::null(),
7373
"Category $i",
74-
new CarbonImmutable()
74+
new CarbonImmutable
7575
);
7676
$categoryRepository->create($category);
7777
}
@@ -97,28 +97,28 @@
9797
});
9898

9999
it('can filter categories with search criteria', function () {
100-
$categoryRepository = new CategoryRepository();
100+
$categoryRepository = new CategoryRepository;
101101

102102
// Create categories with specific labels
103103
$category1 = Category::create(
104104
CategoryId::null(),
105105
'Laravel Category',
106-
new CarbonImmutable()
106+
new CarbonImmutable
107107
);
108108
$categoryRepository->create($category1);
109109

110110
$category2 = Category::create(
111111
CategoryId::null(),
112112
'PHP Tutorial',
113-
new CarbonImmutable()
113+
new CarbonImmutable
114114
);
115115
$category2->subspend();
116116
$categoryRepository->create($category2);
117117

118118
$category3 = Category::create(
119119
CategoryId::null(),
120120
'Laravel Tips',
121-
new CarbonImmutable()
121+
new CarbonImmutable
122122
);
123123
$category3->subspend();
124124
$categoryRepository->create($category3);

tests/Unit/Shared/ValueObjects/IntIdTest.php

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use Contexts\Shared\ValueObjects\IntId;
66

77
// Create a concrete implementation of the abstract IntId class for testing
8-
class ConcreteIntId extends IntId
9-
{
10-
}
8+
class ConcreteIntId extends IntId {}
119

1210
it('can be created from int', function (int $validId) {
1311
$id = ConcreteIntId::fromInt($validId);
@@ -34,7 +32,7 @@ class ConcreteIntId extends IntId
3432
})->with([
3533
[0, true],
3634
[1, false],
37-
[100, false]
35+
[100, false],
3836
]);
3937

4038
it('can be compared with another ID', function (int $value1, int $value2, bool $expected) {
@@ -45,17 +43,17 @@ class ConcreteIntId extends IntId
4543
})->with([
4644
[1, 1, true],
4745
[1, 2, false],
48-
[0, 0, true]
46+
[0, 0, true],
4947
]);
5048

5149
it('can be converted to string', function (int $value, string $expected) {
5250
$id = ConcreteIntId::fromInt($value);
5351

54-
expect((string)$id)->toBe($expected);
52+
expect((string) $id)->toBe($expected);
5553
})->with([
5654
[0, '0'],
5755
[1, '1'],
58-
[100, '100']
56+
[100, '100'],
5957
]);
6058

6159
it('can be serialized and unserialized', function (int $value) {

0 commit comments

Comments
 (0)