for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Chrisyue\PhpM3u8\Transformer;
/**
* @Annotation
*/
class AttributeList implements TransformerInterface
{
public function transform($origin)
preg_match_all('/(?<=^|,)[A-Z0-9-]+=("?).+?\1(?=,|$)/', $origin, $matches);
$attributes = [];
foreach ($matches[0] as $attr) {
list($key, $value) = explode('=', $attr);
$attributes[$key] = trim($value);
}
return $attributes;
public function reverse($attributes)
$keyVals = [];
foreach ($attributes as $name => $attribute) {
$keyVals[] = sprintf('%s=%s', $name, $attribute);
return implode(',', $keyVals);