93 lines
1.2 KiB
PHP
93 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace alveolata\xml;
|
|
|
|
require_once(DIR_ALVEOLATA . '/xml/abstract/interface.php');
|
|
require_once(DIR_ALVEOLATA . '/xml/concrete/text/type.php');
|
|
|
|
|
|
/**
|
|
* @author Christian Fraß <frass@greenscale.de>
|
|
*/
|
|
class implementation_text implements interface_node
|
|
{
|
|
|
|
/**
|
|
* @var \alveolata\xml\struct_text
|
|
*/
|
|
private $subject;
|
|
|
|
|
|
/**
|
|
*/
|
|
public function __construct(
|
|
struct_text $subject
|
|
)
|
|
{
|
|
$this->subject = $subject;
|
|
}
|
|
|
|
|
|
/**
|
|
* @implementation
|
|
*/
|
|
public function find(
|
|
\Closure $sub,
|
|
\Closure $predicate,
|
|
?int $max_depth
|
|
) : array
|
|
{
|
|
return (
|
|
((! \is_null($max_depth)) && ($max_depth <= 0))
|
|
? []
|
|
: (
|
|
($predicate)($this->subject)
|
|
? [$this->subject]
|
|
: []
|
|
)
|
|
);
|
|
}
|
|
|
|
|
|
/**
|
|
* @implementation
|
|
*/
|
|
public function transform(
|
|
\Closure $sub,
|
|
\Closure $function
|
|
)
|
|
{
|
|
return ($function)($this->subject);
|
|
}
|
|
|
|
|
|
/**
|
|
* @implementation
|
|
*/
|
|
public function to_raw(
|
|
\Closure $sub
|
|
)
|
|
{
|
|
return [
|
|
'kind' => 'text',
|
|
'data' => [
|
|
'content' => $this->subject->content,
|
|
],
|
|
];
|
|
}
|
|
|
|
|
|
/**
|
|
* @implementation
|
|
*/
|
|
public function to_string(
|
|
\Closure $sub,
|
|
int $depth
|
|
) : string
|
|
{
|
|
return $this->subject->content;
|
|
}
|
|
|
|
}
|
|
|
|
?>
|