<commit_before><?php

class TimberMenuItem extends TimberCore implements TimberCoreInterface {

    public $children;
    public $has_child_class = false;

    public $classes = array();
    public $class;
    public $post_name;
    public $type;

    private $parent_object;

    /**
     *
     *
     * @param array|object $data
     */
    function __construct( $data ) {
        $this->import( $data );
        $this->import_classes( $data );
        if ( isset( $this->name ) ) {
            $this->_name = $this->name;
        }
        $this->name = $this->name();
        $this->add_class( 'menu-item-' . $this->ID );
        if ( method_exists( $data, 'get_link' ) ) {
            $this->url = untrailingslashit( $data->get_link() );
        }
        $this->parent_object = $data;
    }

    function __toString(){
        return $this->name();
    }

    /**
     *
     *
     * @param string  $class_name
     */
    function add_class( $class_name ) {
        $this->classes[] = $class_name;
        $this->class .= ' ' . $class_name;
    }

    /**
     *
     *
     * @return string
     */
    function name() {
        if ( isset( $this->title ) ) {
            return $this->title;
        }
        if ( isset( $this->_name ) ) {
            return $this->_name;
        }
        return '';
    }

    /**
     *
     *
     * @return string
     */
    function slug() {
        return $this->post_name;
    }

    /**
     *
     *
     * @return string
     */
    function get_link() {
        return untrailingslashit( $this->url );
    }

    /**
     *
     *
     * @return string
     */
    function get_path() {
        return untrailingslashit( TimberURLHelper::get_rel_url( $this->url ) );
    }

    /**
     *
     *
     * @param TimberMenuItem $item
     */
    function add_child( $item ) {
        if ( !$this->has_child_class ) {
            $this->add_class( 'menu-item-has-children' );
            $this->has_child_class = true;
        }
        if ( !isset( $this->children ) ) {
            $this->children = array();
        }
        $this->children[] = $item;
    }<commit_msg>fixed issue with id #276<commit_after><?php

class TimberMenuItem extends TimberCore implements TimberCoreInterface {

    public $children;
    public $has_child_class = false;

    public $classes = array();
    public $class;
    public $post_name;
    public $type;

    private $parent_object;

    /**
     *
     *
     * @param array|object $data
     */
    function __construct( $data ) {
        $this->import( $data );
        $this->import_classes( $data );
        if ( isset( $this->name ) ) {
            $this->_name = $this->name;
        }
        $this->name = $this->name();
        $this->add_class( 'menu-item-' . $this->ID );
        $this->parent_object = $data;
    }

    function __toString() {
        return $this->name();
    }

    /**
     *
     *
     * @param string  $class_name
     */
    function add_class( $class_name ) {
        $this->classes[] = $class_name;
        $this->class .= ' ' . $class_name;
    }

    /**
     *
     *
     * @return string
     */
    function name() {
        if ( isset( $this->title ) ) {
            return $this->title;
        }
        if ( isset( $this->_name ) ) {
            return $this->_name;
        }
        return '';
    }

    /**
     *
     *
     * @return string
     */
    function slug() {
        return $this->post_name;
    }

    /**
     *
     *
     * @return string
     */
    function get_link() {
        if (!isset($this->url)){
            if ( isset( $this->_menu_item_type ) && $this->_menu_item_type == 'custom' ) {
                $this->url = $this->_menu_item_url;
            } else if ( isset($this->parent_object) && method_exists( $this->parent_object, 'get_link' ) ) {
                $this->url = untrailingslashit( $this->parent_object->get_link() );
            }
        }
        return untrailingslashit( $this->url );
    }

    /**
     *
     *
     * @return string
     */
    function get_path() {
        return untrailingslashit( TimberURLHelper::get_rel_url( $this->url ) );
    }

    /**
     *
     *
     * @param TimberMenuItem $item
     */
    function add_child( $item ) {
        if ( !$this->has_child_class ) {
            $this->add_class( 'menu-item-has-children' );
            $this->has_child_class = true;
        }
        if ( !isset( $this->children ) ) {
            $this->children = array();
        }
        $this->children[] = $item;
    }
{'fraction_non_alphanumeric': 0.15659461843846492, 'fraction_numerical': 0.0006616674018526688, 'mean_word_length': 1.5781694144400227, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 67, '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': '4986586', 'n_tokens_mistral': 1471, 'n_tokens_neox': 1443, 'n_words': 257}