Rename GitCommit::FromLogLine and have it accept the full line

This commit is contained in:
Mike Colagrosso 2024-10-23 16:20:09 -06:00 committed by Alex Cabal
parent e9cf55b53f
commit df8eac6f82
2 changed files with 6 additions and 4 deletions

View file

@ -10,14 +10,17 @@ class GitCommit{
/**
* @throws Exceptions\InvalidGitCommitException
*/
public static function FromLog(string $unixTimestamp, string $hash, string $message): GitCommit{
public static function FromLogLine(string $logLine): GitCommit{
$instance = new GitCommit();
list($unixTimestamp, $hash, $message) = explode(' ', $logLine, 3);
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;