@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DiffusionCommitHash extends Phobject {
4
5 private $hashType;
6 private $hashValue;
7
8 public function setHashValue($hash_value) {
9 $this->hashValue = $hash_value;
10 return $this;
11 }
12
13 public function getHashValue() {
14 return $this->hashValue;
15 }
16
17 public function setHashType($hash_type) {
18 $this->hashType = $hash_type;
19 return $this;
20 }
21
22 public function getHashType() {
23 return $this->hashType;
24 }
25
26 public static function convertArrayToObjects(array $hashes) {
27 $hash_objects = array();
28 foreach ($hashes as $hash) {
29 $type = $hash[0];
30 $hash = $hash[1];
31 $hash_objects[] = id(new DiffusionCommitHash())
32 ->setHashType($type)
33 ->setHashValue($hash);
34 }
35 return $hash_objects;
36 }
37
38 public static function newFromDictionary(array $map) {
39 $hash_type = idx($map, 'type');
40 $hash_value = idx($map, 'value');
41
42 return id(new self())
43 ->setHashType($hash_type)
44 ->setHashValue($hash_value);
45 }
46
47 public function newDictionary() {
48 return array(
49 'type' => $this->hashType,
50 'value' => $this->hashValue,
51 );
52 }
53
54}