Path: blob/master/src/applications/diffusion/data/DiffusionCommitRef.php
12241 views
<?php12final class DiffusionCommitRef extends Phobject {34private $message;5private $authorEpoch;6private $authorName;7private $authorEmail;8private $committerName;9private $committerEmail;10private $hashes = array();1112public function newDictionary() {13$hashes = $this->getHashes();14$hashes = mpull($hashes, 'newDictionary');15$hashes = array_values($hashes);1617return array(18'authorEpoch' => $this->authorEpoch,19'authorName' => $this->authorName,20'authorEmail' => $this->authorEmail,21'committerName' => $this->committerName,22'committerEmail' => $this->committerEmail,23'message' => $this->message,24'hashes' => $hashes,25);26}2728public static function newFromDictionary(array $map) {29$hashes = idx($map, 'hashes', array());30foreach ($hashes as $key => $hash_map) {31$hashes[$key] = DiffusionCommitHash::newFromDictionary($hash_map);32}33$hashes = array_values($hashes);3435$author_epoch = idx($map, 'authorEpoch');36$author_name = idx($map, 'authorName');37$author_email = idx($map, 'authorEmail');38$committer_name = idx($map, 'committerName');39$committer_email = idx($map, 'committerEmail');40$message = idx($map, 'message');4142return id(new self())43->setAuthorEpoch($author_epoch)44->setAuthorName($author_name)45->setAuthorEmail($author_email)46->setCommitterName($committer_name)47->setCommitterEmail($committer_email)48->setMessage($message)49->setHashes($hashes);50}5152public function setHashes(array $hashes) {53assert_instances_of($hashes, 'DiffusionCommitHash');54$this->hashes = $hashes;55return $this;56}5758public function getHashes() {59return $this->hashes;60}6162public function setAuthorEpoch($author_epoch) {63$this->authorEpoch = $author_epoch;64return $this;65}6667public function getAuthorEpoch() {68return $this->authorEpoch;69}7071public function setCommitterEmail($committer_email) {72$this->committerEmail = $committer_email;73return $this;74}7576public function getCommitterEmail() {77return $this->committerEmail;78}798081public function setCommitterName($committer_name) {82$this->committerName = $committer_name;83return $this;84}8586public function getCommitterName() {87return $this->committerName;88}899091public function setAuthorEmail($author_email) {92$this->authorEmail = $author_email;93return $this;94}9596public function getAuthorEmail() {97return $this->authorEmail;98}99100101public function setAuthorName($author_name) {102$this->authorName = $author_name;103return $this;104}105106public function getAuthorName() {107return $this->authorName;108}109110public function setMessage($message) {111$this->message = $message;112return $this;113}114115public function getMessage() {116return $this->message;117}118119public function getAuthor() {120return $this->formatUser($this->authorName, $this->authorEmail);121}122123public function getCommitter() {124return $this->formatUser($this->committerName, $this->committerEmail);125}126127public function getSummary() {128return PhabricatorRepositoryCommitData::summarizeCommitMessage(129$this->getMessage());130}131132private function formatUser($name, $email) {133if ($name === null) {134$name = '';135}136if ($email === null) {137$email = '';138}139140if (strlen($name) && strlen($email)) {141return "{$name} <{$email}>";142} else if (strlen($email)) {143return $email;144} else if (strlen($name)) {145return $name;146} else {147return null;148}149}150151}152153154