<?php
require_once OCS_APPLICATION_PATH
    . '/services/Optimization/Helper/Abstract/Base.php';

class Ocs_Service_Optimization_Helper_ExtractHtmlHead
    extends Ocs_Service_Optimization_Helper_Abstract_Base
{
    public function __invoke($html)
    {
        if (preg_match('~<\s*head\b[^>]*>(.*)(?:<\s*/\s*head\s*>|<\s*body\b\s*>)~isu', $html, $matches)) {
            return $matches[1];
        }

        return '';
    }
}
