ipl\Html: allow to get first content element
This commit is contained in:
parent
74351f2146
commit
f06ac06b5b
|
@ -32,6 +32,25 @@ class Html implements ValidHtml
|
|||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $tag
|
||||
* @return BaseElement
|
||||
* @throws ProgrammingError
|
||||
*/
|
||||
public function getFirst($tag)
|
||||
{
|
||||
foreach ($this->content as $c) {
|
||||
if ($c instanceof BaseElement && $c->getTag() === $tag) {
|
||||
return $c;
|
||||
}
|
||||
}
|
||||
|
||||
throw new ProgrammingError(
|
||||
'Trying to get first %s, but there is no such',
|
||||
$tag
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param $content
|
||||
* @return $this
|
||||
|
@ -81,7 +100,7 @@ class Html implements ValidHtml
|
|||
|
||||
/**
|
||||
* @param Html|array|string $content
|
||||
* @return self
|
||||
* @return $this
|
||||
*/
|
||||
public function setContent($content)
|
||||
{
|
||||
|
@ -146,7 +165,7 @@ class Html implements ValidHtml
|
|||
* @param $tag
|
||||
* @param null $attributes
|
||||
* @param null $content
|
||||
* @return Element
|
||||
* @return BaseElement
|
||||
*/
|
||||
public static function tag($tag, $attributes = null, $content = null)
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue