mirror of
https://github.com/standardebooks/web.git
synced 2025-07-12 17:42:29 -04:00
Rename the constructor Ebook::__construct()
to static Ebook::FromFilesystem()
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()`
This commit is contained in:
parent
f605a4df60
commit
2098b265a8
9 changed files with 656 additions and 279 deletions
|
@ -1,17 +1,31 @@
|
|||
<?
|
||||
use function Safe\preg_replace;
|
||||
|
||||
/**
|
||||
* @property string $Url
|
||||
*/
|
||||
class Collection{
|
||||
use Traits\Accessor;
|
||||
|
||||
public string $Name;
|
||||
public string $UrlName;
|
||||
public string $Url;
|
||||
public ?int $SequenceNumber = null;
|
||||
public ?string $Type = null;
|
||||
protected ?string $_Url = null;
|
||||
|
||||
public function __construct(string $name){
|
||||
$this->Name = $name;
|
||||
$this->UrlName = Formatter::MakeUrlSafe($this->Name);
|
||||
$this->Url = '/collections/' . $this->UrlName;
|
||||
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{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue