/ */ namespace Slack; use P4\Spec\Change; use Zend\View\Helper\AbstractHelper; use Zend\Stdlib\StringUtils; /** * Provides persistent storage and indexing of comments. */ class Message extends AbstractHelper { protected $msg = ''; public function __construct($host, Change $change, $max) { $this->msg = $this->formatChange($host, $change, $max); } public function toString() { return $this->msg; } private function formatChange($host, $change, $max) { $id = $change->getId(); $id_url = $host('change', array('change' => $id)); $description = $change->getDescription(); $user = $change->getUser(); $user_url = $host('user', array('user' => $user)); $client = $change->getClient(); $date = $change->getDate(); $summary = "Change " . "<" . $id_url . "|" . $id . ">" . " by " . "<" . $user_url . "|" . $user . "@" . $client . ">" . " on " . $date . "\n"; $utility = StringUtils::getWrapper(); $length = strlen($description); if($length > $description) { $description = $utility->substr($description, 0, $max) . "..."; } $msg = $summary . $description . "\n"; return $msg; } }