diff --git a/lib/Artist.php b/lib/Artist.php
index ed6d165a..93fadcf6 100644
--- a/lib/Artist.php
+++ b/lib/Artist.php
@@ -6,9 +6,12 @@ use Safe\DateTimeImmutable;
* @property ?string $UrlName
* @property ?string $Url
* @property ?array $AlternateNames
- * @property ?array $_AlternateNames
*/
class Artist{
+ /**
+ * @var array $_AlternateNames
+ */
+
use Traits\Accessor;
public ?int $ArtistId = null;
@@ -18,7 +21,7 @@ class Artist{
protected ?int $_DeathYear = null;
protected ?string $_UrlName = null;
protected ?string $_Url = null;
- protected ?array $_AlternateNames = null;
+ protected $_AlternateNames = null; // Don't type hint this here, otherwise PHPStan will complain
// *******
// SETTERS
diff --git a/lib/ArtworkTag.php b/lib/ArtworkTag.php
index 6294a667..b74cdffd 100644
--- a/lib/ArtworkTag.php
+++ b/lib/ArtworkTag.php
@@ -3,14 +3,6 @@ use function Safe\preg_match;
use function Safe\preg_replace;
class ArtworkTag extends Tag{
- // *******
- // SETTERS
- // *******
-
- // protected function SetName($name): void{
- // $this->_Name =
- // }
-
// *******
// GETTERS
// *******
diff --git a/lib/Constants.php b/lib/Constants.php
index c2575377..0e395c49 100644
--- a/lib/Constants.php
+++ b/lib/Constants.php
@@ -72,9 +72,6 @@ const HTTP_PUT = 3;
const HTTP_DELETE = 4;
const HTTP_HEAD = 5;
-const VIEW_GRID = 'grid';
-const VIEW_LIST = 'list';
-
const AVERAGE_READING_WORDS_PER_MINUTE = 275;
const PAYMENT_CHANNEL_FA = 0;
diff --git a/lib/ViewType.php b/lib/ViewType.php
new file mode 100644
index 00000000..e0d66d74
--- /dev/null
+++ b/lib/ViewType.php
@@ -0,0 +1,5 @@
+
+enum ViewType: string{
+ case Grid = 'grid';
+ case List = 'list';
+}
diff --git a/templates/EbookGrid.php b/templates/EbookGrid.php
index cbe4a0c3..46c46b87 100644
--- a/templates/EbookGrid.php
+++ b/templates/EbookGrid.php
@@ -1,13 +1,13 @@
if($view == ''){
- $view = VIEW_GRID;
+ $view = ViewType::Grid;
}
$collection = $collection ?? null;
$ebooks = $ebooks ?? [];
?>
- typeof="schema:BookSeries" about="= $collection->Url ?>" } ?>>
+ typeof="schema:BookSeries" about="= $collection->Url ?>" } ?>>
if($collection !== null){ ?>
} ?>
@@ -26,7 +26,7 @@ $ebooks = $ebooks ?? [];
= Formatter::EscapeHtml($ebook->Title) ?>
- if($view == VIEW_GRID){ ?>
+ if($view == ViewType::Grid){ ?>
foreach($ebook->Authors as $author){ ?>
if($author->Name != 'Anonymous'){ ?>= Formatter::EscapeHtml($author->Name) ?> } ?>
} ?>
diff --git a/templates/SearchForm.php b/templates/SearchForm.php
index a4ca171d..46f6a639 100644
--- a/templates/SearchForm.php
+++ b/templates/SearchForm.php
@@ -28,8 +28,8 @@ $allSelected = sizeof($tags) == 0 || in_array('all', $tags);
View
diff --git a/www/artworks/post.php b/www/artworks/post.php
index 0060601e..720a5376 100644
--- a/www/artworks/post.php
+++ b/www/artworks/post.php
@@ -155,8 +155,6 @@ catch(Exceptions\ArtworkNotFoundException){
Template::Emit404();
}
catch(Exceptions\AppException $exception){
- $artwork = $artwork ?? null;
-
$_SESSION['artwork'] = $artwork;
$_SESSION['exception'] = $exception;
diff --git a/www/collections/get.php b/www/collections/get.php
index ecee2588..449a1a8b 100644
--- a/www/collections/get.php
+++ b/www/collections/get.php
@@ -49,7 +49,7 @@ catch(Exceptions\CollectionNotFoundException){
if(sizeof($ebooks) == 0){ ?>
No ebooks matched your filters. You can try different filters, or browse all of our ebooks.
}else{ ?>
- = Template::EbookGrid(['ebooks' => $ebooks, 'view' => VIEW_GRID, 'collection' => $collectionObject]) ?>
+ = Template::EbookGrid(['ebooks' => $ebooks, 'view' => ViewType::Grid, 'collection' => $collectionObject]) ?>
} ?>
We also have bulk ebook downloads and a list of collections available, as well as ebook catalog feeds for use directly in your ereader app or RSS reader.
diff --git a/www/ebooks/author.php b/www/ebooks/author.php
index b7401244..c3ac4fdb 100644
--- a/www/ebooks/author.php
+++ b/www/ebooks/author.php
@@ -31,7 +31,7 @@ catch(Exceptions\AuthorNotFoundException){
Download collection
Feeds for this author
- = Template::EbookGrid(['ebooks' => $ebooks, 'view' => VIEW_GRID]) ?>
+ = Template::EbookGrid(['ebooks' => $ebooks, 'view' => ViewType::Grid]) ?>
We also have bulk ebook downloads and a list of collections available, as well as ebook catalog feeds for use directly in your ereader app or RSS reader.
= Template::ContributeAlert() ?>
diff --git a/www/ebooks/index.php b/www/ebooks/index.php
index 6ce9f8cf..5cda083b 100644
--- a/www/ebooks/index.php
+++ b/www/ebooks/index.php
@@ -5,7 +5,7 @@ $page = HttpInput::Int(GET, 'page') ?? 1;
$perPage = HttpInput::Int(GET, 'per-page') ?? EBOOKS_PER_PAGE;
$query = HttpInput::Str(GET, 'query') ?? '';
$tags = HttpInput::GetArray('tags') ?? [];
-$view = HttpInput::Str(GET, 'view');
+$view = ViewType::tryFrom(HttpInput::Str(GET, 'view') ?? '');
$sort = EbookSort::tryFrom(HttpInput::Str(GET, 'sort') ?? '');
$queryString = '';
$queryStringParams = [];
@@ -21,11 +21,7 @@ try{
// If we're passed string values that are the same as the defaults,
// set them to null so that we can have cleaner query strings in the navigation footer
- if($view !== null){
- $view = mb_strtolower($view);
- }
-
- if($view === 'grid'){
+ if($view === ViewType::Grid){
$view = null;
}
@@ -44,7 +40,6 @@ try{
$totalEbooks = sizeof($ebooks);
$ebooks = array_slice($ebooks, ($page - 1) * $perPage, $perPage);
-
if($page > 1){
$pageTitle .= ', page ' . $page;
}
@@ -60,7 +55,7 @@ try{
}
if($view !== null){
- $queryStringParams['view'] = $view;
+ $queryStringParams['view'] = $view->value;
}
if($sort !== null){