forked from chrisyue/php-m3u8
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattributeValueDumpers.php
39 lines (33 loc) · 1.11 KB
/
attributeValueDumpers.php
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
<?php
declare(strict_types=1);
/*
* This file is part of the PhpM3u8 package.
*
* (c) Chrisyue <https://chrisyue.com/>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
use Chrisyue\PhpM3u8\Data\Transformer\Iso8601Transformer;
$quotedStringDump = fn ($value) => sprintf('"%s"', $value);
/*
* @see https://tools.ietf.org/html/rfc8216#section-4.2
*/
return [
'decimal-integer' => 'strval',
'hexadecimal-sequence' => 'strval',
'decimal-floating-point' => 'strval',
'signed-decimal-floating-point' => 'strval',
'quoted-string' => $quotedStringDump,
'enumerated-string' => 'strval',
'decimal-resolution' => 'strval', // Resolution is __toString able
// special
'datetime' => fn ($value) => $quotedStringDump(Iso8601Transformer::toString($value)),
'byterange' => $quotedStringDump, // Byterange is __toString able
'closed-captions' => function ($value) use ($quotedStringDump) {
if (null === $value) {
return 'NONE';
}
return $quotedStringDump($value);
},
];