@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 AlmanacAddress extends Phobject {
4
5 private $networkPHID;
6 private $address;
7 private $port;
8
9 private function __construct() {
10 // <private>
11 }
12
13 public function getNetworkPHID() {
14 return $this->networkPHID;
15 }
16
17 public function getAddress() {
18 return $this->address;
19 }
20
21 public function getPort() {
22 return $this->port;
23 }
24
25 public static function newFromDictionary(array $dictionary) {
26 return self::newFromParts(
27 $dictionary['networkPHID'],
28 $dictionary['address'],
29 $dictionary['port']);
30 }
31
32 public static function newFromParts($network_phid, $address, $port) {
33 $addr = new AlmanacAddress();
34
35 $addr->networkPHID = $network_phid;
36 $addr->address = $address;
37 $addr->port = (int)$port;
38
39 return $addr;
40 }
41
42 public function toDictionary() {
43 return array(
44 'networkPHID' => $this->getNetworkPHID(),
45 'address' => $this->getAddress(),
46 'port' => $this->getPort(),
47 );
48 }
49
50 public function toHash() {
51 return PhabricatorHash::digestForIndex(json_encode($this->toDictionary()));
52 }
53
54}