for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Sioen\HtmlToJson;
class IframeConverter extends Converter
{
public function toJson(\DOMElement $node)
$html = $node->ownerDocument->saveXML($node);
// youtube or vimeo
if (preg_match('~//www.youtube.com/embed/([^/\?]+).*\"~si', $html, $matches)) {
return array(
'type' => 'video',
'data' => array(
'source' => 'youtube',
'remote_id' => $matches[1]
)
);
} elseif (preg_match('~//player.vimeo.com/video/([^/\?]+).*\?~si', $html, $matches)) {
'source' => 'vimeo',
}
public function matches(\DomElement $node)
return $node->nodeName === 'iframe';