Path: blob/master/src/applications/herald/storage/transcript/HeraldObjectTranscript.php
12261 views
<?php12final class HeraldObjectTranscript extends Phobject {34protected $phid;5protected $type;6protected $name;7protected $fields;8protected $appliedTransactionPHIDs;9protected $profile;1011public function setPHID($phid) {12$this->phid = $phid;13return $this;14}1516public function getPHID() {17return $this->phid;18}1920public function setType($type) {21$this->type = $type;22return $this;23}2425public function getType() {26return $this->type;27}2829public function setName($name) {30$this->name = $name;31return $this;32}3334public function getName() {35return $this->name;36}3738public function setFields(array $fields) {39foreach ($fields as $key => $value) {40$fields[$key] = self::truncateValue($value, 4096);41}4243$this->fields = $fields;44return $this;45}4647public function getFields() {48return $this->fields;49}5051public function setProfile(array $profile) {52$this->profile = $profile;53return $this;54}5556public function getProfile() {57return $this->profile;58}5960public function setAppliedTransactionPHIDs($phids) {61$this->appliedTransactionPHIDs = $phids;62return $this;63}6465public function getAppliedTransactionPHIDs() {66return $this->appliedTransactionPHIDs;67}6869private static function truncateValue($value, $length) {70if (is_string($value)) {71if (strlen($value) <= $length) {72return $value;73} else {74// NOTE: PhutilUTF8StringTruncator has huge runtime for giant strings.75return phutil_utf8ize(substr($value, 0, $length)."\n<...>");76}77} else if (is_array($value)) {78foreach ($value as $key => $v) {79if ($length <= 0) {80$value['<...>'] = '<...>';81unset($value[$key]);82} else {83$v = self::truncateValue($v, $length);84$length -= strlen($v);85$value[$key] = $v;86}87}88return $value;89} else {90return $value;91}92}9394}959697