mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 23:00:28 -04:00
Collection validation: Pass enum to InvalidCollectionTypeException, not value
This commit is contained in:
parent
754fc0ab2b
commit
2273367c6d
2 changed files with 6 additions and 4 deletions
|
@ -60,7 +60,7 @@ class Collection{
|
||||||
}
|
}
|
||||||
|
|
||||||
if($this->Type !== null && ($this->Type != CollectionType::Series && $this->Type != CollectionType::Set)){
|
if($this->Type !== null && ($this->Type != CollectionType::Series && $this->Type != CollectionType::Set)){
|
||||||
$error->Add(new Exceptions\InvalidCollectionTypeException($this->Type->value));
|
$error->Add(new Exceptions\InvalidCollectionTypeException($this->Type));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($error->HasExceptions){
|
if($error->HasExceptions){
|
||||||
|
|
|
@ -2,13 +2,15 @@
|
||||||
|
|
||||||
namespace Exceptions;
|
namespace Exceptions;
|
||||||
|
|
||||||
|
use \CollectionType;
|
||||||
|
|
||||||
class InvalidCollectionTypeException extends AppException{
|
class InvalidCollectionTypeException extends AppException{
|
||||||
/** @var string $message */
|
/** @var string $message */
|
||||||
protected $message = 'Collection type should be `series` or `set` according to the EPUB specification.';
|
protected $message = 'Collection type should be `series` or `set` according to the EPUB specification.';
|
||||||
|
|
||||||
public function __construct(?string $collectionType){
|
public function __construct(?CollectionType $collectionType){
|
||||||
if($collectionType !== null && trim($collectionType) != ''){
|
if($collectionType !== null){
|
||||||
$this->message .= ' Type provided: ' . $collectionType;
|
$this->message .= ' Type provided: ' . $collectionType->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
parent::__construct($this->message);
|
parent::__construct($this->message);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue