mirror of
https://github.com/standardebooks/web.git
synced 2025-07-06 06:40:33 -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()`
24 lines
599 B
PHP
24 lines
599 B
PHP
<?
|
|
use Safe\DateTimeImmutable;
|
|
|
|
class GitCommit{
|
|
public DateTimeImmutable $Created;
|
|
public string $Message;
|
|
public string $Hash;
|
|
|
|
/**
|
|
* @throws Exceptions\InvalidGitCommitException
|
|
*/
|
|
public static function FromLog(string $unixTimestamp, string $hash, string $message): GitCommit{
|
|
$instance = new GitCommit();
|
|
try{
|
|
$instance->Created = new DateTimeImmutable('@' . $unixTimestamp);
|
|
}
|
|
catch(\Exception){
|
|
throw new Exceptions\InvalidGitCommitException('Invalid timestamp for Git commit.');
|
|
}
|
|
$instance->Message = $message;
|
|
$instance->Hash = $hash;
|
|
return $instance;
|
|
}
|
|
}
|