mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 14:50:39 -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
|
@ -9,14 +9,16 @@ class GitCommit{
|
|||
/**
|
||||
* @throws Exceptions\InvalidGitCommitException
|
||||
*/
|
||||
public function __construct(string $unixTimestamp, string $hash, string $message){
|
||||
public static function FromLog(string $unixTimestamp, string $hash, string $message): GitCommit{
|
||||
$instance = new GitCommit();
|
||||
try{
|
||||
$this->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
||||
$instance->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
||||
}
|
||||
catch(\Exception){
|
||||
throw new Exceptions\InvalidGitCommitException('Invalid timestamp for Git commit.');
|
||||
}
|
||||
$this->Message = $message;
|
||||
$this->Hash = $hash;
|
||||
$instance->Message = $message;
|
||||
$instance->Hash = $hash;
|
||||
return $instance;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue