Add MessageFactory, MessageByNameFactory.

This commit is contained in:
2023-09-01 12:22:08 +03:00
parent 2b37a4c2e7
commit 02cdb1f792
3 changed files with 69 additions and 0 deletions
@@ -0,0 +1,35 @@
<?php
namespace App\Models\Validation\Messages\Factories;
use App\Models\Validation\Messages\Factories\MessageFactory;
class MessageByNameFactory extends MessageFactory
{
private string $name;
public function __construct(string $name)
{
$this->setName($name);
}
public function setName(string $name): void
{
$this->name = $name;
}
public function getName(): string
{
return $this->name;
}
public function create(): array
{
return [
'found' => "A $this->name with the name is valid.",
'not_found' => "A $this->name with the name does not exist!!!",
'invalid_name' => "The $this->name name is empty, please, write the name!!!",
];
}
}
@@ -0,0 +1,9 @@
<?php
namespace App\Models\Validation\Messages\Factories;
abstract class MessageFactory
{
abstract function create(): array;
}