Add ValidationByName and CompanyValidationByName.
continuous-integration/drone/push Build is passing
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Validation\Messages;
|
||||
|
||||
use App\Models\Validation\ValidationStatus;
|
||||
|
||||
class BaseMessages
|
||||
{
|
||||
protected array $messages;
|
||||
|
||||
public function __construct($messages)
|
||||
{
|
||||
$this->messages = $messages;
|
||||
}
|
||||
|
||||
public function getMessage($status): string
|
||||
{
|
||||
return match($status)
|
||||
{
|
||||
ValidationStatus::FOUND => $this->messages['found'],
|
||||
ValidationStatus::NOT_FOUND => $this->messages['not_found'],
|
||||
ValidationStatus::INVALID_NAME => $this->messages['invalid_name'],
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
<?php
|
||||
|
||||
namespace App\Models\Validation\Messages;
|
||||
|
||||
use App\Models\Validation\Messages\BaseMessages;
|
||||
|
||||
class CompanyMessagesFactory
|
||||
{
|
||||
protected array $messages = [
|
||||
'found' => 'A company with the name is valid.',
|
||||
'not_found' => 'A company with the name does not exist!!!',
|
||||
'invalid_name' => 'The company name is empty, please, write the name!!!',
|
||||
];
|
||||
|
||||
public function create()
|
||||
{
|
||||
return new BaseMessages($this->messages);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user