Skip to content

Commit

Permalink
Refactor de la liste des antennes en DTOs
Browse files Browse the repository at this point in the history
  • Loading branch information
Mopolo committed Jan 20, 2025
1 parent cf646d3 commit 752061f
Show file tree
Hide file tree
Showing 7 changed files with 241 additions and 0 deletions.
51 changes: 51 additions & 0 deletions sources/AppBundle/Offices/Antenne.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

/**
* @readonly
*/
final class Antenne
{
public string $code;
public string $label;
public Position $position;
public Meetup $meetup;
public string $logoUrl;
public Socials $socials;
public Map $map;

/** @var array<string> */
public array $departments;

/** @var array<string>|null */
public ?array $pays;

/**
* @param string[] $departments
* @param string[] $pays
*/
public function __construct(
string $code,
string $label,
Position $position,
Meetup $meetup,
string $logoUrl,
Socials $socials,
Map $map,
array $departments,
?array $pays
) {
$this->code = $code;
$this->label = $label;
$this->position = $position;
$this->meetup = $meetup;
$this->logoUrl = $logoUrl;
$this->socials = $socials;
$this->departments = $departments;
$this->pays = $pays;
$this->map = $map;
}
}
47 changes: 47 additions & 0 deletions sources/AppBundle/Offices/AntennesCollection.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

final class AntennesCollection
{
/** @var list<Antenne> */
private array $antennes;

public function __construct()
{
$this->antennes[] = new Antenne(
'bordeaux',
'Bordeaux',
new Position('44.837912', '-0.579541'),
new Meetup('bordeaux-php-meetup', '18197674'),
'/images/offices/bordeaux.svg',
new Socials(
null,
null,
'AFUP_Bordeaux',
'afup-bordeaux',
'bordeaux.afup.org',
),
new Map(
new Point('330', '440'),
new Point('270', '500'),
new Point('230', '500'),
new Position('44.837912', '-0.579541'),
false,
'right',
),
['33'],
null,
);
}

/**
* @return list<Antenne>
*/
public function getAll(): array
{
return $this->antennes;
}
}
52 changes: 52 additions & 0 deletions sources/AppBundle/Offices/Map.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

/**
* @readonly
*/
final class Map
{
public Point $legendFirstPoint;
public Point $legendSecondPoint;
public Point $legendThirdPoint;
public Position $point;

public bool $useSecondColor;
public string $legendAttachment;

public ?Point $legendSecondCityFirstPoint;

Check failure on line 20 in sources/AppBundle/Offices/Map.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class AppBundle\Offices\Map has an uninitialized @readonly property $legendSecondCityFirstPoint. Assign it in the constructor.
public ?Point $legendSecondCitySecondPoint;

Check failure on line 21 in sources/AppBundle/Offices/Map.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class AppBundle\Offices\Map has an uninitialized @readonly property $legendSecondCitySecondPoint. Assign it in the constructor.
public ?Point $legendSecondCityThirdPoint;

Check failure on line 22 in sources/AppBundle/Offices/Map.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class AppBundle\Offices\Map has an uninitialized @readonly property $legendSecondCityThirdPoint. Assign it in the constructor.
public ?Position $pointSecondCity;

Check failure on line 23 in sources/AppBundle/Offices/Map.php

View workflow job for this annotation

GitHub Actions / PHPStan

Class AppBundle\Offices\Map has an uninitialized @readonly property $pointSecondCity. Assign it in the constructor.

public function __construct(
Point $legendFirstPoint,
Point $legendSecondPoint,
Point $legendThirdPoint,
Position $point,
bool $useSecondColor,
string $legendAttachment
) {
$this->legendFirstPoint = $legendFirstPoint;
$this->legendSecondPoint = $legendSecondPoint;
$this->legendThirdPoint = $legendThirdPoint;
$this->point = $point;
$this->useSecondColor = $useSecondColor;
$this->legendAttachment = $legendAttachment;
}

public function withSecondCity(
?Point $legendSecondCityFirstPoint,
?Point $legendSecondCitySecondPoint,
?Point $legendSecondCityThirdPoint,
?Position $pointSecondCity
) {
$this->legendSecondCityFirstPoint = $legendSecondCityFirstPoint;
$this->legendSecondCitySecondPoint = $legendSecondCitySecondPoint;
$this->legendSecondCityThirdPoint = $legendSecondCityThirdPoint;
$this->pointSecondCity = $pointSecondCity;
}
}
20 changes: 20 additions & 0 deletions sources/AppBundle/Offices/Meetup.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

/**
* @readonly
*/
final class Meetup
{
public string $urlName;
public string $id;

public function __construct(string $urlName, string $id)
{
$this->urlName = $urlName;
$this->id = $id;
}
}
20 changes: 20 additions & 0 deletions sources/AppBundle/Offices/Point.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

/**
* @readonly
*/
final class Point
{
public string $x;
public string $y;

public function __construct(string $x, string $y)
{
$this->x = $x;
$this->y = $y;
}
}
20 changes: 20 additions & 0 deletions sources/AppBundle/Offices/Position.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

/**
* @readonly
*/
final class Position
{
public string $latitude;
public string $longitude;

public function __construct(string $latitude, string $longitude)
{
$this->latitude = $latitude;
$this->longitude = $longitude;
}
}
31 changes: 31 additions & 0 deletions sources/AppBundle/Offices/Socials.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<?php

declare(strict_types=1);

namespace AppBundle\Offices;

/**
* @readonly
*/
final class Socials
{
public ?string $youtube;
public ?string $blog;
public ?string $twitter;
public ?string $linkedin;
public ?string $bluesky;

public function __construct(
?string $youtube,
?string $blog,
?string $twitter,
?string $linkedin,
?string $bluesky
) {
$this->youtube = $youtube;
$this->blog = $blog;
$this->twitter = $twitter;
$this->linkedin = $linkedin;
$this->bluesky = $bluesky;
}
}

0 comments on commit 752061f

Please sign in to comment.