forked from php-soap/encoding
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElementValueReader.php
More file actions
48 lines (43 loc) · 1.13 KB
/
ElementValueReader.php
File metadata and controls
48 lines (43 loc) · 1.13 KB
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
<?php
declare(strict_types=1);
namespace Soap\Encoding\Xml\Reader;
use DOMElement;
use Soap\Encoding\Encoder\Context;
use Soap\Encoding\Encoder\XmlEncoder;
use VeeWee\Reflecta\Iso\Iso;
use function Psl\Type\string;
use function VeeWee\Xml\Dom\Locator\Node\value as readValue;
final class ElementValueReader
{
/**
* @param XmlEncoder<mixed, string> $encoder
* @psalm-return mixed
*/
public function __invoke(
Context $context,
XmlEncoder $encoder,
DOMElement $element
): mixed {
return self::forEncoder($context, $encoder, $element);
}
/**
* @param XmlEncoder<mixed, string> $encoder
* @psalm-return mixed
*/
public static function forEncoder(Context $context, XmlEncoder $encoder, DOMElement $element): mixed
{
return $encoder->iso($context)->from(
readValue($element, string())
);
}
/**
* @param Iso<mixed, string> $iso
* @psalm-return mixed
*/
public static function forIso(Iso $iso, DOMElement $element): mixed
{
return $iso->from(
readValue($element, string())
);
}
}