ldc-cocotte/app/Cqs/Actions/Ranges/CreateRangeInput.php
Jérémy Munsch d0efb0f527
refactor: update namespaces for actions and queries
Refactored the codebase to change the namespaces of various actions and queries from `App\Actions` to `App\Cqs\Actions` and `App\Queries` to `App\Cqs\Queries`. This restructuring improves organization and clarity in the codebase.
2026-11-10 15:13:26 +01:00

33 lines
1.3 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Cqs\Actions\Ranges;
use App\Contracts\ActionInput;
use Domain\Models\ValueObjects\PictureMetadata;
use Illuminate\Http\UploadedFile;
use Webmozart\Assert\Assert;
final readonly class CreateRangeInput implements ActionInput
{
public function __construct(
public string $name,
public ?string $description,
public UploadedFile | string | null $picture,
public PictureMetadata $pictureMetadata,
public bool $status,
) {
$trimmedName = trim($this->name);
Assert::stringNotEmpty($trimmedName, 'The range name cannot be empty.');
Assert::minLength($trimmedName, 2, 'The range name must be at least 2 characters.');
Assert::maxLength($trimmedName, 45, 'The range name cannot exceed 45 characters.');
if ($this->picture !== null) {
Assert::notNull($this->pictureMetadata->alt, 'Picture alt is required when picture is provided.');
Assert::stringNotEmpty(trim($this->pictureMetadata->alt), 'Picture alt cannot be empty when picture is provided.');
Assert::notNull($this->pictureMetadata->title, 'Picture title is required when picture is provided.');
Assert::stringNotEmpty(trim($this->pictureMetadata->title), 'Picture title cannot be empty when picture is provided.');
}
}
}