-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
factory and strategy to apply rules for a project. add tests
- Loading branch information
1 parent
63b018b
commit 24263b5
Showing
8 changed files
with
104 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
core/Domain/Entities/Project/StatusValidation/Strategies/PendingValidation.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
namespace Core\Domain\Entities\Project\StatusValidation\Strategies; | ||
|
||
use Core\Domain\Entities\Project\ProjectEntity; | ||
use Core\Domain\Entities\Project\StatusValidation\StatusValidationInterface; | ||
use Core\Support\Exceptions\Dates\DateNotAllowedException; | ||
|
||
readonly class PendingValidation implements StatusValidationInterface | ||
{ | ||
public function __construct(private ProjectEntity $projectEntity) | ||
{ | ||
} | ||
|
||
/** | ||
* @throws DateNotAllowedException | ||
*/ | ||
public function validate(): void | ||
{ | ||
if ($this->projectEntity->getFinishAt() !== null) { | ||
throw new DateNotAllowedException('Project must not have a finish date when status is pending'); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
namespace Core\Support\Exceptions\Dates; | ||
|
||
use Core\Support\Exceptions\OutputErrorException; | ||
use Core\Support\Http\ResponseStatus; | ||
use Exception; | ||
|
||
class DateNotAllowedException extends OutputErrorException | ||
{ | ||
public function __construct( | ||
string $message, | ||
int $code = ResponseStatus::FORBIDDEN->value, | ||
Exception $previous = null, | ||
?array $errors = [] | ||
) { | ||
parent::__construct($message, $code, $previous, $errors); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters