Add PropertyFromHttp trait and update codebase to use new pattern

This commit is contained in:
Alex Cabal 2024-11-10 22:23:43 -06:00
parent c35c47b793
commit acb30b897c
47 changed files with 851 additions and 527 deletions

View file

@ -13,6 +13,11 @@ class Collection{
public ?Enums\CollectionType $Type = null;
protected ?string $_Url = null;
// *******
// GETTERS
// *******
protected function GetUrl(): string{
if($this->_Url === null){
$this->_Url = '/collections/' . $this->UrlName;
@ -21,6 +26,11 @@ class Collection{
return $this->_Url;
}
// ***********
// ORM METHODS
// ***********
public static function FromName(string $name): Collection{
$instance = new Collection();
$instance->Name = $name;
@ -45,6 +55,11 @@ class Collection{
return $result[0] ?? throw new Exceptions\CollectionNotFoundException();;
}
// *******
// METHODS
// *******
public function GetSortedName(): string{
return preg_replace('/^(the|and|a|)\s/ius', '', $this->Name);
}