Bart\Git\Commit::author PHP Method

author() public method

The author of the commit (person who originally wrote the work)
public author ( ) : Person
return Person
    public function author()
    {
        $name = $this->gitShowFormatOutput('%%aN', 'Could not get name of author');
        $email = $this->gitShowFormatOutput('%%aE', 'Could not get email of author');
        return new Person($name, $email);
    }

Usage Example

Beispiel #1
0
 public function testAuthor()
 {
     $expectedName = 'Author Name';
     $expectedEmail = '*****@*****.**';
     $gitRoot = $this->shmock('\\Bart\\Git\\GitRoot', function ($root) use($expectedName, $expectedEmail) {
         $nameResultStub = new StubbedCommandResult([$expectedName], 0);
         $emailResultStub = new StubbedCommandResult([$expectedEmail], 0);
         $root->order_matters();
         $root->getCommandResult("show -s --no-color --format='%%aN' HEAD")->once()->return_value($nameResultStub);
         $root->getCommandResult("show -s --no-color --format='%%aE' HEAD")->once()->return_value($emailResultStub);
     });
     $commit = new Commit($gitRoot, 'HEAD');
     $person = $commit->author();
     $actualName = $person->getName();
     $actualEmail = $person->getEmail();
     $this->assertSame($expectedName, $actualName);
     $this->assertSame($expectedEmail, $actualEmail);
 }