for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Chrisyue\PhpM3u8\Parser;
use Chrisyue\PhpM3u8\Line\Line;
use Chrisyue\PhpM3u8\Config;
class AttributeListParser
{
private $valueParsers;
public function __construct(Config $valueParsers)
$this->valueParsers = $valueParsers;
}
public function parse($value, array $types)
preg_match_all('/(?<=^|,)[A-Z0-9-]+=("?).+?\1(?=,|$)/', $value, $matches);
$result = new \ArrayObject();
foreach ($matches[0] as $attr) {
list($name, $value) = explode('=', $attr);
$result[$name] = $value;
if (!isset($types[$name])) {
continue;
$type = $types[$name];
$parse = $this->valueParsers->get($type);
if (is_callable($parse)) {
$result[$name] = $parse($value);
return $result;