<commit_before><?php
/**
 * File containing the ezcFeedTools class.
 *
 * @package Feed
 * @version //autogentag//
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 * @filesource
 */

/**
 * Utility class providing useful functions to manipulate XML files.
 *
 * @package Feed
 * @version //autogentag//
 */
class ezcFeedTools
{
    /**
     * Returns the value of attribute $name of the XML node $node, or null
     * if the attribute is not found.
     *
     * @apichange Deprecated (duplicates DOMElement->getAttribute()) - will be removed
     *
     * @param DOMNode $node The XML node
     * @param string $name The name of the attribute to return its value
     * @return mixed
     * @ignore
     */
    public static function getAttribute( DOMNode $node, $name )
    {
        if ( $node->hasAttributes() )
        {
            foreach ( $node->attributes as $attribute )
            {
                if ( $attribute->name === $name )
                {
                    return $attribute->value;
                }
            }
        }

        return null;
    }

    /**
     * Returns an array containing the names and values of the attributes of
     * the XML node $node.
     *
     * @apichange Deprecated (duplicates DOMElement->attributes) - will be removed
     *
     * @param DOMNode $node The XML node
     * @return array(string=>mixed)
     * @ignore
     */
    public static function getAttributes( DOMNode $node )
    {
        $result = array();
        if ( $node->hasAttributes() )
        {
            foreach ( $node->attributes as $attribute )
            {
                $result[$attribute->name] = $attribute->value;
            }
        }

        return $result;
    }

    /**
     * Returns a DOMNode child of $parent with name $nodeName and which has an
     * attribute $attribute with the value $value. Returns null if no such node
     * is found.
     *
     * @param DOMNode $parent The XML parent node
     * @param string $nodeName The node name to find
     * @param string $attribute The attribute of the node
     * @param mixed $value The value of the attribute
     * @return DOMNode
     */
    public static function getNodeByAttribute( DOMNode $parent, $nodeName, $attribute, $value )
    {
        $result = null;
        $nodes = $parent->getElementsByTagName( $nodeName );

        foreach ( $nodes as $node )
        {
            $nodeAttribute = $node->getAttribute( $attribute );
            if ( $nodeAttribute !== null
                 && $nodeAttribute === $value )
            {
                $result = $node;
                break;
            }
        }

        return $result;<commit_msg>- Removed deprecated functions (Feed was never released as stable).<commit_after><?php
/**
 * File containing the ezcFeedTools class.
 *
 * @package Feed
 * @version //autogentag//
 * @copyright Copyright (C) 2005-2008 eZ systems as. All rights reserved.
 * @license http://ez.no/licenses/new_bsd New BSD License
 * @filesource
 */

/**
 * Utility class providing useful functions to manipulate XML files, date
 * functions and functions to normalize/denormalize feed element names.
 *
 * @package Feed
 * @version //autogentag//
 */
class ezcFeedTools
{
    /**
     * Returns a DOMNode child of $parent with name $nodeName and which has an
     * attribute $attribute with the value $value. Returns null if no such node
     * is found.
     *
     * @param DOMNode $parent The XML parent node
     * @param string $nodeName The node name to find
     * @param string $attribute The attribute of the node
     * @param mixed $value The value of the attribute
     * @return DOMNode
     */
    public static function getNodeByAttribute( DOMNode $parent, $nodeName, $attribute, $value )
    {
        $result = null;
        $nodes = $parent->getElementsByTagName( $nodeName );

        foreach ( $nodes as $node )
        {
            $nodeAttribute = $node->getAttribute( $attribute );
            if ( $nodeAttribute !== null
                 && $nodeAttribute === $value )
            {
                $result = $node;
                break;
            }
        }

        return $result;
{'fraction_non_alphanumeric': 0.10204561486009875, 'fraction_numerical': 0.0037620503174229957, 'mean_word_length': 1.9831697054698456, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 18, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1326508', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1120, 'n_words': 398}