rosavox/lib/alveolata/xml/concrete/comment/implementation.php

94 lines
1.2 KiB
PHP
Raw Normal View History

2025-05-23 07:33:29 +00:00
<?php
namespace alveolata\xml;
require_once(DIR_ALVEOLATA . '/xml/abstract/interface.php');
require_once(DIR_ALVEOLATA . '/xml/concrete/comment/type.php');
/**
* @author Christian Fraß <frass@greenscale.de>
*/
class implementation_comment implements interface_node
{
/**
* @var \alveolata\xml\struct_comment
*/
private $subject;
/**
*/
public function __construct(
struct_comment $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' => 'comment',
'data' => [
'content' => $this->subject->content,
],
];
}
/**
* @implementation
*/
public function to_string(
\Closure $sub,
int $depth
) : string
{
return ('<!-- ' . $this->subject->content . ' -->');
}
}
?>