Skip to content

Commit

Permalink
Merge pull request #72 from programmatordev/2.x
Browse files Browse the repository at this point in the history
v2.2.0
  • Loading branch information
andrepimpao authored Oct 7, 2024
2 parents c696b5b + a96246f commit 8ab7763
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 0 deletions.
11 changes: 11 additions & 0 deletions docs/05-entities.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- [Player](#player)
- [PlayerStatistic](#playerstatistic)
- [PlayerStatisticDetail](#playerstatisticdetail)
- [Ranking](#ranking)
- [Referee](#referee)
- [RefereeStatistic](#refereestatistic)
- [RefereeStatisticDetail](#refereestatisticdetail)
Expand Down Expand Up @@ -496,6 +497,15 @@
- `getValue()`: `array`
- `getType()`: [`?Type`](#type) (`type` include is required)

### Ranking

- `getId()`: `?int`
- `getParticipantId()`: `?int`
- `getSportId()`: `?int`
- `getPosition()`: `?int`
- `getPoints()`: `?int`
- `getType()`: `?string`

### Referee

- `getId()`: `int`
Expand Down Expand Up @@ -779,6 +789,7 @@
- `getSocials()`: [`?Social[]`](#social) (`scoails` include is required)
- `getCoaches()`: [`?TeamCoach[]`](#teamcoach) (`coaches` include is required)
- `getStatistics()`: [`?TeamStatistic[]`](#teamstatistic) (`statistics` include is required)
- `getRankings()`: [`?Ranking[]`](#ranking) (`rankings` include is required)

### TeamCoach

Expand Down
59 changes: 59 additions & 0 deletions src/Entity/Ranking.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?php

namespace ProgrammatorDev\SportMonksFootball\Entity;

class Ranking
{
private ?int $id;

private ?int $participantId;

private ?int $sportId;

private ?int $position;

private ?int $points;

private ?string $type;

public function __construct(array $data)
{
// select
$this->id = $data['id'] ?? null;
$this->participantId = $data['participant_id'] ?? null;
$this->sportId = $data['sport_id'] ?? null;
$this->position = $data['position'] ?? null;
$this->points = $data['points'] ?? null;
$this->type = $data['type'] ?? null;
}

public function getId(): ?int
{
return $this->id;
}

public function getParticipantId(): ?int
{
return $this->participantId;
}

public function getSportId(): ?int
{
return $this->sportId;
}

public function getPosition(): ?int
{
return $this->position;
}

public function getPoints(): ?int
{
return $this->points;
}

public function getType(): ?string
{
return $this->type;
}
}
9 changes: 9 additions & 0 deletions src/Entity/Team.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,9 @@ class Team
/** @var ?TeamStatistic[] */
private ?array $statistics;

/** @var ?Ranking[] */
private ?array $rankings;

public function __construct(array $data, string $timezone)
{
$this->id = $data['id'];
Expand Down Expand Up @@ -107,6 +110,7 @@ public function __construct(array $data, string $timezone)
$this->socials = isset($data['socials']) ? $this->createEntityCollection(Social::class, $data['socials']) : null;
$this->coaches = isset($data['coaches']) ? $this->createEntityCollection(TeamCoach::class, $data['coaches'], $timezone) : null;
$this->statistics = isset($data['statistics']) ? $this->createEntityCollection(TeamStatistic::class, $data['statistics'], $timezone) : null;
$this->rankings = isset($data['rankings']) ? $this->createEntityCollection(Ranking::class, $data['rankings']) : null;
}

public function getId(): int
Expand Down Expand Up @@ -243,4 +247,9 @@ public function getStatistics(): ?array
{
return $this->statistics;
}

public function getRankings(): ?array
{
return $this->rankings;
}
}
28 changes: 28 additions & 0 deletions tests/Unit/RankingTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace ProgrammatorDev\SportMonksFootball\Test\Unit;

use ProgrammatorDev\SportMonksFootball\Entity\Ranking;
use ProgrammatorDev\SportMonksFootball\Test\AbstractTest;

class RankingTest extends AbstractTest
{
public function testMethods(): void
{
$entity = new Ranking([
'id' => 1,
'participant_id' => 1,
'sport_id' => 1,
'position' => 1,
'points' => 1,
'type' => 'type'
]);

$this->assertSame(1, $entity->getId());
$this->assertSame(1, $entity->getParticipantId());
$this->assertSame(1, $entity->getSportId());
$this->assertSame(1, $entity->getPosition());
$this->assertSame(1, $entity->getPoints());
$this->assertSame('type', $entity->getType());
}
}

0 comments on commit 8ab7763

Please sign in to comment.