Skip to content

Commit 70b8f59

Browse files
committed
feat: added numResults to AirPollutionCollection entity
1 parent e35e1e2 commit 70b8f59

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/Entity/AirPollution/AirPollutionCollection.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,25 @@ class AirPollutionCollection
99
{
1010
use EntityTrait;
1111

12+
private int $numResults;
13+
1214
private Coordinate $coordinate;
1315

1416
/** @var AirPollutionData[] */
1517
private array $data;
1618

1719
public function __construct(array $data)
1820
{
21+
$this->numResults = \count($data['list']);
1922
$this->coordinate = new Coordinate($data['coord']);
2023
$this->data = $this->createEntityList(AirPollutionData::class, $data['list']);
2124
}
2225

26+
public function getNumResults(): int
27+
{
28+
return $this->numResults;
29+
}
30+
2331
public function getCoordinate(): Coordinate
2432
{
2533
return $this->coordinate;

tests/Unit/AirPollution/AirPollutionCollectionTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ public function testMethods()
3636
]
3737
]);
3838

39+
$this->assertSame(1, $entity->getNumResults());
3940
$this->assertInstanceOf(Coordinate::class, $entity->getCoordinate());
4041
$this->assertContainsOnlyInstancesOf(AirPollutionData::class, $entity->getData());
4142
}

0 commit comments

Comments
 (0)