Collection validation: Pass enum to InvalidCollectionTypeException, not value

This commit is contained in:
Mike Colagrosso 2024-10-03 14:05:53 -06:00 committed by Alex Cabal
parent 754fc0ab2b
commit 2273367c6d
2 changed files with 6 additions and 4 deletions

View file

@ -2,13 +2,15 @@
namespace Exceptions;
use \CollectionType;
class InvalidCollectionTypeException extends AppException{
/** @var string $message */
protected $message = 'Collection type should be `series` or `set` according to the EPUB specification.';
public function __construct(?string $collectionType){
if($collectionType !== null && trim($collectionType) != ''){
$this->message .= ' Type provided: ' . $collectionType;
public function __construct(?CollectionType $collectionType){
if($collectionType !== null){
$this->message .= ' Type provided: ' . $collectionType->value;
}
parent::__construct($this->message);