composed project, added packages, models, controllers, seeders, mirgations etc.
This commit is contained in:
70
app/Services/Faker/Image/ImageStorage.php
Normal file
70
app/Services/Faker/Image/ImageStorage.php
Normal file
@@ -0,0 +1,70 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package: events-venues-task
|
||||
* @author: Yevhen Odynets
|
||||
* @date: 2024-07-26
|
||||
* @time: 19:20
|
||||
*/
|
||||
|
||||
//phpcs:ignore
|
||||
declare(strict_types = 1);
|
||||
|
||||
namespace App\Services\Faker\Image;
|
||||
|
||||
use Illuminate\Support\Arr;
|
||||
|
||||
class ImageStorage
|
||||
{
|
||||
private string $destFolder;
|
||||
private int $width;
|
||||
private int $height;
|
||||
private array $keywords;
|
||||
|
||||
public function __construct(string $destFolder, int $width, int $height, array $keywords = [])
|
||||
{
|
||||
$this->destFolder = $destFolder;
|
||||
$this->width = $width;
|
||||
$this->height = $height;
|
||||
$this->keywords = $keywords;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getFolder(): string
|
||||
{
|
||||
return $this->destFolder;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getWidth(): int
|
||||
{
|
||||
return $this->width;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return int
|
||||
*/
|
||||
public function getHeight(): int
|
||||
{
|
||||
return $this->height;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $prefix
|
||||
* @param string $suffix
|
||||
*
|
||||
* @return string|null
|
||||
*/
|
||||
public function getKeyword(string $prefix = '', string $suffix = ''): ?string
|
||||
{
|
||||
if (count($this->keywords) === 0) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $prefix . Arr::random($this->keywords) . $suffix;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user