From db8d4221338669e3d47449c44733c83e42520056 Mon Sep 17 00:00:00 2001 From: Alex Cabal Date: Wed, 15 Jan 2025 16:16:45 -0600 Subject: [PATCH] Simplify validation logic --- lib/Contributor.php | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/lib/Contributor.php b/lib/Contributor.php index 19c5b0cf..6c100a49 100644 --- a/lib/Contributor.php +++ b/lib/Contributor.php @@ -73,19 +73,14 @@ class Contributor{ $error->Add(new Exceptions\ContributorEbookIdRequiredException()); } - if(isset($this->Name)){ - $this->Name = trim($this->Name); - if($this->Name == ''){ - $error->Add(new Exceptions\ContributorNameRequiredException()); - } - else{ - // Sometimes placeholders may have `'` in the name. - $this->Name = str_replace('\'', '’', $this->Name); - } + $this->Name = trim($this->Name ?? ''); + if($this->Name == ''){ + $error->Add(new Exceptions\ContributorNameRequiredException()); } else{ - $error->Add(new Exceptions\ContributorNameRequiredException()); + // Sometimes placeholders may have `'` in the name. + $this->Name = str_replace('\'', '’', $this->Name); } if(isset($this->UrlName)){