private static function buildAttributes($htmlAttributes, $ignore = array())
    {
        if (empty($htmlAttributes))
        {
            return '';
        }

        if ($ignore === null) {
            $ignore = array();
        }

        $filtered = array_filter($htmlAttributes, function($key) use ($ignore) {
            return !in_array($key, $ignore);
        }, \ARRAY_FILTER_USE_KEY);

        array_walk($filtered, function(&$value, $key) {
            $value = sprintf('%s="%s"', $key, self::encodeHtmlAttributeString($value));
        });

        return implode(' ', $filtered);
    }