-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathfilter.php
More file actions
52 lines (44 loc) · 1013 Bytes
/
filter.php
File metadata and controls
52 lines (44 loc) · 1013 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php
namespace shgysk8zer0\DOMValidator;
final class Filter extends \ArrayObject
{
use Traits\Filters;
protected $_input;
public function __construct(\DOMElement $input)
{
parent::__construct([
'filter' => FILTER_CALLBACK,
'options' => [$this, 'validate']
]);
$this->_input = $input;
//$this->filter(FILTER_CALLBACK)->options($this, 'validate');
}
public function __set($prop, $value)
{
$this->_input->setAttribute($prop, $value);
}
public function __get($prop)
{
return $this->_input->getAttribute($prop);
}
public function __isset($prop)
{
return $this->_input->hasAttribute($prop);
}
public function __call($prop, Array $args)
{
if (!empty($args)) {
$this[$prop] = count($args) === 1 ? $args[0] : $args;
}
return $this;
}
public function __invoke($value)
{
echo $value . PHP_EOL;
if (!empty($value)) {
$this->_input->setAttribute('value', $value);
}
echo $this->_input->ownerDocument->saveHTML($this->_input) . PHP_EOL;
return $value;
}
}