<commit_before><?php
declare(strict_types = 1);

namespace ASN1\Type\Primitive;

use ASN1\Element;
use ASN1\Component\Identifier;
use ASN1\Component\Length;
use ASN1\Exception\DecodeException;
use ASN1\Feature\ElementBase;
use ASN1\Type\PrimitiveType;
use ASN1\Type\UniversalClass;

/**
 * Implements <i>OBJECT IDENTIFIER</i> type.
 */
class ObjectIdentifier extends Element
{
    use UniversalClass;
    use PrimitiveType;
    
    /**
     * Object identifier in dotted format.
     *
     * @var string
     */
    protected $_oid;
    
    /**
     * Object identifier split to sub ID's.
     *
     * @var \GMP[]
     */
    protected $_subids;
    
    /**
     * Constructor.
     *
     * @param string $oid OID in dotted format
     */
    public function __construct(string $oid)
    {
        $this->_oid = $oid;
        $this->_subids = self::_explodeDottedOID($oid);
        if (count($this->_subids) > 0) {
            if (count($this->_subids) < 2) {
                throw new \UnexpectedValueException(
                    "OID must have at least two arcs.");
            }
            if ($this->_subids[0] > 2) {
                throw new \UnexpectedValueException(
                    "First arc must be less or equal to 2.");
            }
            if ($this->_subids[0] < 2 && $this->_subids[1] >= 40) {
                throw new \UnexpectedValueException(
                    "Second arc must be less than 40 for root arcs 0 and 1.");
            }
        }
        $this->_typeTag = self::TYPE_OBJECT_IDENTIFIER;
    }
    
    /**
     * Get OID in dotted format.
     *
     * @return string
     */
    public function oid(): string
    {
        return $this->_oid;
    }
    
    /**
     *
     * {@inheritdoc}<commit_msg>Clarify error messages<commit_after><?php
declare(strict_types = 1);

namespace ASN1\Type\Primitive;

use ASN1\Element;
use ASN1\Component\Identifier;
use ASN1\Component\Length;
use ASN1\Exception\DecodeException;
use ASN1\Feature\ElementBase;
use ASN1\Type\PrimitiveType;
use ASN1\Type\UniversalClass;

/**
 * Implements <i>OBJECT IDENTIFIER</i> type.
 */
class ObjectIdentifier extends Element
{
    use UniversalClass;
    use PrimitiveType;
    
    /**
     * Object identifier in dotted format.
     *
     * @var string
     */
    protected $_oid;
    
    /**
     * Object identifier split to sub ID's.
     *
     * @var \GMP[]
     */
    protected $_subids;
    
    /**
     * Constructor.
     *
     * @param string $oid OID in dotted format
     */
    public function __construct(string $oid)
    {
        $this->_oid = $oid;
        $this->_subids = self::_explodeDottedOID($oid);
        // if OID is non-empty
        if (count($this->_subids) > 0) {
            // check that at least two nodes are set
            if (count($this->_subids) < 2) {
                throw new \UnexpectedValueException(
                    "OID must have at least two nodes.");
            }
            // check that root arc is in 0..2 range
            if ($this->_subids[0] > 2) {
                throw new \UnexpectedValueException(
                    "Root arc must be in range of 0..2.");
            }
            // if root arc is 0 or 1, second node must be in 0..39 range
            if ($this->_subids[0] < 2 && $this->_subids[1] >= 40) {
                throw new \UnexpectedValueException(
                    "Second node must be in 0..39 range for root arcs 0 and 1.");
            }
        }
        $this->_typeTag = self::TYPE_OBJECT_IDENTIFIER;
    }
    
    /**
     * Get OID in dotted format.
     *
     * @return string
     */
    public function oid(): string
    {
        return $this->_oid;
    }
    
    /**
     *
     * {@inheritdoc}
{'fraction_non_alphanumeric': 0.11799410029498525, 'fraction_numerical': 0.014749262536873156, 'mean_word_length': 1.7087872185911401, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 31, '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': '6977051', 'n_tokens_mistral': 1168, 'n_tokens_neox': 1112, 'n_words': 302}