🎉 initial commit

This commit is contained in:
2024-10-07 22:58:27 +02:00
commit d3eccf99f0
824 changed files with 16401 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
<?php
namespace Application\Generator;
class Article extends WebsiteObjectGenerator
{
public function __construct(protected readonly string $seed)
{
parent::__construct($seed);
}
private function getHeadline(): string
{
return $this->getGenerator()->sentence(8);
}
private function getKicker(): string
{
return $this->getGenerator()->word();
}
private function getTeaserImage(): array
{
return (new Image($this->getSeed()))->getImage(640, 480);
}
private function getHeroImage(): array
{
return (new Image($this->getSeed()))->getImage(1920, 1080);
}
private function getExcerpt(): string
{
return implode(' ', $this->getGenerator()->sentences(5));
}
private function getUrl(): string
{
return '/article/test-' . $this->getSeed();
}
public function getTeaserData(): array
{
return [
'headline' => $this->getHeadline(),
'kicker' => $this->getKicker(),
'excerpt' => $this->getExcerpt(),
'teaserImage' => $this->getTeaserImage(),
'url' => $this->getUrl(),
];
}
public function getFullData(): array
{
return [
'headline' => $this->getHeadline(),
'kicker' => $this->getKicker(),
'excerpt' => $this->getExcerpt(),
'heroImage' => $this->getHeroImage(),
'url' => $this->getUrl(),
];
}
}

View File

@@ -0,0 +1,23 @@
<?php
namespace Application\Generator;
use Application\Generator\WebsiteObjectGenerator;
class Image extends WebsiteObjectGenerator
{
public function __construct(protected readonly string $seed)
{
parent::__construct($seed);
}
public function getImage(int $width = 1280, int $height = 720): array
{
return [
'src' => 'https://picsum.photos/seed/' . $this->seed . "/$width/$height",
'width' => $width,
'height' => $height,
'alt' => $this->getGenerator()->sentence(),
];
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Application\Generator;
use Faker\Factory;
use Faker\Generator;
class WebsiteObjectGenerator
{
/**
* @var Generator
*/
private Generator $generator;
public function __construct(private readonly string $seed)
{
$this->generator = Factory::create();
$this->getGenerator()->seed($this->seed);
}
protected function getGenerator(): Generator
{
return $this->generator;
}
protected function getSeed(): string
{
return $this->seed;
}
}