mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 23:00:28 -04:00
Also added `GetFoo()` methods for all the derived properties like `GetUrl()`, `GetHasDownloads()`, etc. Removed that logic from the constructor so that it's reusable in `Ebook::FromFilesystem()` and `Ebook::GetByIdentifier()`
34 lines
724 B
PHP
34 lines
724 B
PHP
<?
|
|
use function Safe\preg_replace;
|
|
|
|
/**
|
|
* @property string $Url
|
|
*/
|
|
class Collection{
|
|
use Traits\Accessor;
|
|
|
|
public string $Name;
|
|
public string $UrlName;
|
|
public ?int $SequenceNumber = null;
|
|
public ?string $Type = null;
|
|
protected ?string $_Url = null;
|
|
|
|
protected function GetUrl(): ?string{
|
|
if($this->_Url === null){
|
|
$this->Url = '/collections/' . $this->UrlName;
|
|
}
|
|
|
|
return $this->_Url;
|
|
}
|
|
|
|
public static function FromName(string $name): Collection{
|
|
$instance = new Collection();
|
|
$instance->Name = $name;
|
|
$instance->UrlName = Formatter::MakeUrlSafe($instance->Name);
|
|
return $instance;
|
|
}
|
|
|
|
public function GetSortedName(): string{
|
|
return preg_replace('/^(the|and|a|)\s/ius', '', $this->Name);
|
|
}
|
|
}
|