Initial commit; implement enough code to get Git_Repo->log() semi-working.
[phpgit.git] / library / Git / Actor.php
blobde3504aae7857ee89d44ba558dddbeaee951fdf8
1 <?php
3 /**
4 * An actor, either a committer or an author.
5 */
6 class Git_Actor {
8 /**
9 * Name of actor.
11 public $name;
13 /**
14 * Email of actor.
16 public $email;
18 public function __construct($name, $email = null) {
19 $this->name = $name;
20 $this->email = $email;
22 public function __toString() {
23 return $this->name;
26 /**
27 * Parses a string from John Doe <jdoe@example.com> to this object.
29 public static function fromString($string) {
30 if (preg_match('/(.*) <(.+?)>/', $string, $matches)) {
31 list($x, $name, $email) = $matches;
32 return new Git_Actor($name, $email);
33 } else {
34 return new Git_Actor($string);