*/ function mst_email_reply_filter($fragment) { return !$fragment->isHidden(); } final class Email { /** * @var Fragment[] */ private $fragments; public function __construct(array $fragments = array()) { $this->fragments = $fragments; } /** * @return Fragment[] */ public function getFragments() { return $this->fragments; } /** * @return string */ public function getVisibleText() { $visibleFragments = array_filter($this->fragments, 'mst_email_reply_filter'); return rtrim(implode("\n", $visibleFragments)); } }