<commit_before><?php
/**
 * This file is part of the PHP Open Doc library.
 *
 * @author <NAME> <<EMAIL>>
 * @since  1.0
 * 
 */
namespace PHPDOC\Element;

use PHPDOC\Property\Properties,
    PHPDOC\Property\PropertiesInterface;

/**
 * Base "Element" class for all document elements.
 *
 * Elements can optionally subclass this base class to provide some helpful
 * shortcuts that all elements should have. If you don't subclass this base
 * class you must at least implement ElementInterface.
 * 
 * @version 1.0
 * @since 1.0
 * @author <NAME>  <<EMAIL>>
 */
class Element implements ElementInterface
{
    protected $properties;
    protected $elements;

    public function __construct($properties = null)
    {
        $this->elements = array();
        if ($properties) {
            $this->setProperties($properties);
        } else {
            $this->properties = new Properties();
        }
    }
    
    public function getInterface()
    {
        $r = new \ReflectionClass($this);
        foreach ($r->getInterfaceNames() as $interface) {
            // simple return the first interface that is not ElementInterface
            if (strpos($interface, 'ElementInterface') == false) {
                return $interface;
            }
        }
        return 'ElementInterface';  // failsafe; shouldn't happen
    }

    public function setProperties($properties)
    {
        if (is_array($properties)) {
            $properties = new Properties($properties);
        }
        if (!($properties instanceof PropertiesInterface)) {
            $type = gettype($properties);
            if ($type == 'object') {
                $type = get_class($properties);
            }
            throw new \InvalidArgumentException("Unexpected properties type of \"$type\" given. Expected PropertiesInterface or array.");
        }
        $this->properties = $properties;
    }

    public function getProperties()
    {
        return $this->properties;<commit_msg>Return proper namespace as failsafe<commit_after><?php
/**
 * This file is part of the PHP Open Doc library.
 *
 * @author <NAME> <<EMAIL>>
 * @since  1.0
 * 
 */
namespace PHPDOC\Element;

use PHPDOC\Property\Properties,
    PHPDOC\Property\PropertiesInterface;

/**
 * Base "Element" class for all document elements.
 *
 * Elements can optionally subclass this base class to provide some helpful
 * shortcuts that all elements should have. If you don't subclass this base
 * class you must at least implement ElementInterface.
 * 
 * @version 1.0
 * @since 1.0
 * @author <NAME>  <<EMAIL>>
 */
class Element implements ElementInterface
{
    protected $properties;
    protected $elements;

    public function __construct($properties = null)
    {
        $this->elements = array();
        if ($properties) {
            $this->setProperties($properties);
        } else {
            $this->properties = new Properties();
        }
    }
    
    public function getInterface()
    {
        $r = new \ReflectionClass($this);
        foreach ($r->getInterfaceNames() as $interface) {
            // simply return the first interface that is not ElementInterface
            if (strpos($interface, 'ElementInterface') == false) {
                return $interface;
            }
        }
        return __NAMESPACE__ . '\\ElementInterface';  // failsafe; shouldn't happen; except in testing
    }

    public function setProperties($properties)
    {
        if (is_array($properties)) {
            $properties = new Properties($properties);
        }
        if (!($properties instanceof PropertiesInterface)) {
            $type = gettype($properties);
            if ($type == 'object') {
                $type = get_class($properties);
            }
            throw new \InvalidArgumentException("Unexpected properties type of \"$type\" given. Expected PropertiesInterface or array.");
        }
        $this->properties = $properties;
    }

    public function getProperties()
    {
        return $this->properties;
{'fraction_non_alphanumeric': 0.11091681239070697, 'fraction_numerical': 0.0029977516862353237, 'mean_word_length': 2.3675357443229603, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 27, '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': '7474818', 'n_tokens_mistral': 1027, 'n_tokens_neox': 991, 'n_words': 315}