Changeset View
Changeset View
Standalone View
Standalone View
src/applications/diffusion/data/DiffusionCommitRef.php
<?php | <?php | ||||
final class DiffusionCommitRef extends Phobject { | final class DiffusionCommitRef extends Phobject { | ||||
private $message; | private $message; | ||||
private $authorEpoch; | private $authorEpoch; | ||||
private $authorName; | private $authorName; | ||||
private $authorEmail; | private $authorEmail; | ||||
private $committerName; | private $committerName; | ||||
private $committerEmail; | private $committerEmail; | ||||
private $hashes = array(); | private $hashes = array(); | ||||
public static function newFromConduitResult(array $result) { | public function newDictionary() { | ||||
$ref = id(new DiffusionCommitRef()) | $hashes = $this->getHashes(); | ||||
->setAuthorEpoch(idx($result, 'authorEpoch')) | $hashes = mpull($hashes, 'newDictionary'); | ||||
->setCommitterEmail(idx($result, 'committerEmail')) | $hashes = array_values($hashes); | ||||
->setCommitterName(idx($result, 'committerName')) | |||||
->setAuthorEmail(idx($result, 'authorEmail')) | return array( | ||||
->setAuthorName(idx($result, 'authorName')) | 'authorEpoch' => $this->authorEpoch, | ||||
->setMessage(idx($result, 'message')); | 'authorName' => $this->authorName, | ||||
'authorEmail' => $this->authorEmail, | |||||
$hashes = array(); | 'committerName' => $this->committerName, | ||||
foreach (idx($result, 'hashes', array()) as $hash_result) { | 'committerEmail' => $this->committerEmail, | ||||
$hashes[] = id(new DiffusionCommitHash()) | 'message' => $this->message, | ||||
->setHashType(idx($hash_result, 'type')) | 'hashes' => $hashes, | ||||
->setHashValue(idx($hash_result, 'value')); | ); | ||||
} | |||||
public static function newFromDictionary(array $map) { | |||||
$hashes = idx($map, 'hashes', array()); | |||||
foreach ($hashes as $key => $hash_map) { | |||||
$hashes[$key] = DiffusionCommitHash::newFromDictionary($hash_map); | |||||
} | |||||
$hashes = array_values($hashes); | |||||
$author_epoch = idx($map, 'authorEpoch'); | |||||
$author_name = idx($map, 'authorName'); | |||||
$author_email = idx($map, 'authorEmail'); | |||||
$committer_name = idx($map, 'committerName'); | |||||
$committer_email = idx($map, 'committerEmail'); | |||||
$message = idx($map, 'message'); | |||||
return id(new self()) | |||||
->setAuthorEpoch($author_epoch) | |||||
->setAuthorName($author_name) | |||||
->setAuthorEmail($author_email) | |||||
->setCommitterName($committer_name) | |||||
->setCommitterEmail($committer_email) | |||||
->setMessage($message) | |||||
->setHashes($hashes); | |||||
} | } | ||||
$ref->setHashes($hashes); | public static function newFromConduitResult(array $result) { | ||||
return self::newFromDictionary($result); | |||||
return $ref; | |||||
} | } | ||||
public function setHashes(array $hashes) { | public function setHashes(array $hashes) { | ||||
assert_instances_of($hashes, 'DiffusionCommitHash'); | |||||
$this->hashes = $hashes; | $this->hashes = $hashes; | ||||
return $this; | return $this; | ||||
} | } | ||||
public function getHashes() { | public function getHashes() { | ||||
return $this->hashes; | return $this->hashes; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 83 Lines • Show Last 20 Lines |