[ Index ] |
PHP Cross Reference of Phabricator |
[Summary view] [Print] [Text view]
1 <?php 2 3 final class HeraldObjectTranscript { 4 5 protected $phid; 6 protected $type; 7 protected $name; 8 protected $fields; 9 10 public function setPHID($phid) { 11 $this->phid = $phid; 12 return $this; 13 } 14 15 public function getPHID() { 16 return $this->phid; 17 } 18 19 public function setType($type) { 20 $this->type = $type; 21 return $this; 22 } 23 24 public function getType() { 25 return $this->type; 26 } 27 28 public function setName($name) { 29 $this->name = $name; 30 return $this; 31 } 32 33 public function getName() { 34 return $this->name; 35 } 36 37 public function setFields(array $fields) { 38 foreach ($fields as $key => $value) { 39 $fields[$key] = self::truncateValue($value, 4096); 40 } 41 42 $this->fields = $fields; 43 return $this; 44 } 45 46 public function getFields() { 47 return $this->fields; 48 } 49 50 private static function truncateValue($value, $length) { 51 if (is_string($value)) { 52 if (strlen($value) <= $length) { 53 return $value; 54 } else { 55 // NOTE: PhutilUTF8StringTruncator has huge runtime for giant strings. 56 return phutil_utf8ize(substr($value, 0, $length)."\n<...>"); 57 } 58 } else if (is_array($value)) { 59 foreach ($value as $key => $v) { 60 if ($length <= 0) { 61 $value['<...>'] = '<...>'; 62 unset($value[$key]); 63 } else { 64 $v = self::truncateValue($v, $length); 65 $length -= strlen($v); 66 $value[$key] = $v; 67 } 68 } 69 return $value; 70 } else { 71 return $value; 72 } 73 } 74 75 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
Generated: Sun Nov 30 09:20:46 2014 | Cross-referenced by PHPXref 0.7.1 |