Skip to content

Commit bbcfae8

Browse files
committed
there is no need for an iterator in the current implementation
1 parent 52f144f commit bbcfae8

File tree

4 files changed

+2
-39
lines changed

4 files changed

+2
-39
lines changed

src/Pet/Dto/Collection/PetCollectionResponse.php

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@
1212
* @property PetCollectionSort $sort
1313
* @property array<PetResponse> $items
1414
*
15-
* @implements \IteratorAggregate<string, mixed>
16-
*
1715
* @phpstan-type JsonSerializedResult array{
1816
* offset: int,
1917
* limit: int,
@@ -50,7 +48,7 @@
5048
*
5149
* @method JsonSerializedResult jsonSerialize()
5250
*/
53-
final readonly class PetCollectionResponse extends AbstractReadonlyCollectionResponse implements \IteratorAggregate
51+
final readonly class PetCollectionResponse extends AbstractReadonlyCollectionResponse
5452
{
5553
public function __construct(
5654
int $offset,
@@ -73,9 +71,4 @@ public function __construct(
7371
$_links,
7472
);
7573
}
76-
77-
public function getIterator(): \Traversable
78-
{
79-
return new \ArrayIterator(get_object_vars($this));
80-
}
8174
}

src/Pet/Dto/Model/PetResponse.php

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,7 @@
66

77
use Chubbyphp\Api\Dto\Model\ModelResponseInterface;
88

9-
/**
10-
* @implements \IteratorAggregate<string, mixed>
11-
*/
12-
final readonly class PetResponse implements \IteratorAggregate, ModelResponseInterface
9+
final readonly class PetResponse implements ModelResponseInterface
1310
{
1411
/**
1512
* @param array<VaccinationResponse> $vaccinations
@@ -65,9 +62,4 @@ public function jsonSerialize(): array
6562
'_links' => $this->_links,
6663
];
6764
}
68-
69-
public function getIterator(): \Traversable
70-
{
71-
return new \ArrayIterator(get_object_vars($this));
72-
}
7365
}

tests/Unit/Pet/Dto/Collection/PetCollectionResponseTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,5 @@ public function testCreateCollection(): void
8080
'_type' => 'petCollection',
8181
'_links' => [],
8282
], $petCollectionResponse->jsonSerialize());
83-
84-
self::assertSame([
85-
'offset' => 5,
86-
'limit' => 10,
87-
'filters' => $petCollectionFilters,
88-
'sort' => $petCollectionSort,
89-
'items' => [$petResponse],
90-
'count' => 1,
91-
'_type' => 'petCollection',
92-
'_links' => [],
93-
], [...$petCollectionResponse]);
9483
}
9584
}

tests/Unit/Pet/Dto/Model/PetResponseTest.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -46,16 +46,5 @@ public function testCreateCollection(): void
4646
'_type' => 'pet',
4747
'_links' => [],
4848
], $petResponse->jsonSerialize());
49-
50-
self::assertSame([
51-
'id' => '019c201f-6a83-7696-9899-50fbf7b2278d',
52-
'createdAt' => '2024-02-10T18:15:00+00:00',
53-
'updatedAt' => '2024-02-10T18:15:00+00:00',
54-
'name' => 'jerry',
55-
'tag' => 'tag',
56-
'vaccinations' => [$vaccinationResponse],
57-
'_type' => 'pet',
58-
'_links' => [],
59-
], [...$petResponse]);
6049
}
6150
}

0 commit comments

Comments
 (0)