From 70f03e7d88d55acbc30c9a6e75b248aabeb0802e Mon Sep 17 00:00:00 2001 From: Joby Elliott Date: Tue, 9 Jul 2019 11:13:08 -0600 Subject: [PATCH] adding option to hide tags fully --- src/TagInterface.php | 1 + src/TagTrait.php | 14 ++++++++++++++ 2 files changed, 15 insertions(+) diff --git a/src/TagInterface.php b/src/TagInterface.php index b52867d..3643634 100644 --- a/src/TagInterface.php +++ b/src/TagInterface.php @@ -11,6 +11,7 @@ interface TagInterface public function hasClass(string $name) : bool; public function removeClass(string $name); public function classes() : array; + public function hidden($hidden=null); public function string() : string; diff --git a/src/TagTrait.php b/src/TagTrait.php index 430bf14..e651898 100644 --- a/src/TagTrait.php +++ b/src/TagTrait.php @@ -10,6 +10,15 @@ trait TagTrait protected $classes = []; protected $attributes = []; + protected $hidden = false; + + public function hidden($hidden=null) + { + if ($hidden !== null) { + $this->hidden = $hidden; + } + return $this->hidden; + } protected function htmlContent() { @@ -79,6 +88,11 @@ trait TagTrait public function string() : string { + //output empty string if hidden + if ($this->hidden()) { + return ''; + } + //build output $out = ''; //build opening tag $out .= '<'.$this->tag;