Add getSponsors body, Sponsor model
This commit is contained in:
parent
e3ba387f86
commit
83d21c1c10
33
src/Sponsors/src/Model/Sponsor.php
Normal file
33
src/Sponsors/src/Model/Sponsor.php
Normal file
|
@ -0,0 +1,33 @@
|
|||
<?php
|
||||
|
||||
namespace App\Sponsors\Model;
|
||||
|
||||
class Sponsor
|
||||
{
|
||||
/** @var array */
|
||||
private $data = [];
|
||||
|
||||
private function __construct(array $sponsorData)
|
||||
{
|
||||
$this->data = $sponsorData;
|
||||
}
|
||||
|
||||
public static function create(array $sponsorData): self
|
||||
{
|
||||
return new static($sponsorData);
|
||||
}
|
||||
|
||||
public function isConfirmed(): bool
|
||||
{
|
||||
if (!isset($this->data['confirmed'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->data['confirmed'];
|
||||
}
|
||||
|
||||
public function getData(): array
|
||||
{
|
||||
return $this->data;
|
||||
}
|
||||
}
|
|
@ -22,5 +22,12 @@ class SponsorsExtension extends AbstractExtension
|
|||
|
||||
public function getSponsors(array $sponsorData, string $level): array
|
||||
{
|
||||
return collect($sponsorData[$level])
|
||||
->map(function ($sponsor) {
|
||||
return Sponsor::create($sponsor);
|
||||
})
|
||||
->filter->isConfirmed()
|
||||
->map->getData()
|
||||
->toArray();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue