mirror of
https://github.com/standardebooks/web.git
synced 2025-07-15 19:06:49 -04:00
Fix PHPStan errors for CollectionType enum
Use the `value` property of PHP enums to get the underlying string for functions that expect a string. Followup to #392
This commit is contained in:
parent
b792dec9e5
commit
9a4da8f961
3 changed files with 4 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));
|
$error->Add(new Exceptions\InvalidCollectionTypeException($this->Type->value));
|
||||||
}
|
}
|
||||||
|
|
||||||
if($error->HasExceptions){
|
if($error->HasExceptions){
|
||||||
|
|
|
@ -23,7 +23,7 @@ try{
|
||||||
}
|
}
|
||||||
|
|
||||||
$collectionName = preg_replace('/^The /ius', '', $collectionObject->Name);
|
$collectionName = preg_replace('/^The /ius', '', $collectionObject->Name);
|
||||||
$collectionType = $collectionObject->Type ?? 'collection';
|
$collectionType = $collectionObject->Type->value ?? 'collection';
|
||||||
|
|
||||||
$pageTitle = 'Browse free ebooks in the ' . Formatter::EscapeHtml($collectionName) . ' ' . $collectionType;
|
$pageTitle = 'Browse free ebooks in the ' . Formatter::EscapeHtml($collectionName) . ' ' . $collectionType;
|
||||||
$pageDescription = 'A list of free ebooks in the ' . Formatter::EscapeHtml($collectionName) . ' ' . $collectionType;
|
$pageDescription = 'A list of free ebooks in the ' . Formatter::EscapeHtml($collectionName) . ' ' . $collectionType;
|
||||||
|
|
|
@ -129,8 +129,8 @@ catch(Exceptions\EbookNotFoundException){
|
||||||
<? $sequenceNumber = $collectionMembership->SequenceNumber; ?>
|
<? $sequenceNumber = $collectionMembership->SequenceNumber; ?>
|
||||||
<p><? if($sequenceNumber !== null){ ?>№ <?= number_format($sequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?> <a href="<?= $collection->Url ?>" property="schema:isPartOf"><?= Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?></a>
|
<p><? if($sequenceNumber !== null){ ?>№ <?= number_format($sequenceNumber) ?> in the<? }else{ ?>Part of the<? } ?> <a href="<?= $collection->Url ?>" property="schema:isPartOf"><?= Formatter::EscapeHtml(preg_replace('/^The /ius', '', (string)$collection->Name)) ?></a>
|
||||||
<? if($collection->Type !== null){ ?>
|
<? if($collection->Type !== null){ ?>
|
||||||
<? if(substr_compare(mb_strtolower($collection->Name), mb_strtolower($collection->Type), -strlen(mb_strtolower($collection->Type))) !== 0){ ?>
|
<? if(substr_compare(mb_strtolower($collection->Name), mb_strtolower($collection->Type->value), -strlen(mb_strtolower($collection->Type->value))) !== 0){ ?>
|
||||||
<?= $collection->Type ?>.
|
<?= $collection->Type->value ?>.
|
||||||
<? } ?>
|
<? } ?>
|
||||||
<? }else{ ?>
|
<? }else{ ?>
|
||||||
collection.
|
collection.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue