<commit_before><?php

declare(strict_types=1);

/*
 * This file is part of Badcow DNS Library.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Badcow\DNS\Rdata;

/**
 * Used to create RData of types that have not yet been implemented in the library.
 */
class PolymorphicRdata implements RdataInterface
{
    /**
     * The RData type.
     *
     * @var string
     */
    private $type;

    /**
     * @var string|null
     */
    private $data;

    /**
     * @var int|null
     */
    private $typeCode;

    /**
     * PolymorphicRdata constructor.
     *
     * @param string|null $type
     * @param string|null $data
     */
    public function __construct(?string $type = null, ?string $data = null)
    {
        if (null !== $type) {
            $this->setType($type);
        }

        if (null !== $data) {
            $this->setData($data);
        }
    }

    /**
     * @param string $type
     */
    public function setType(string $type): void
    {
        try {
            $this->typeCode = Types::getTypeCode($type);
        } catch (UnsupportedTypeException $e) {
            $this->typeCode = 0;
        }
        $this->type = $type;
    }

    /**
     * {@inheritdoc}
     */
    public function getType(): string
    {
        return $this->type;
    }

    /**
     * {@inheritdoc}
     */
    public function getTypeCode(): int
    {
        return $this->typeCode;
    }

    /**
     * @param string $data
     */
    public function setData(string $data): void
    {
        $this->data = $data;
    }

    /**
     * @return string|null
     */
    public function getData(): ?string
    {
        return $this->data;
    }

    /**
     * {@inheritdoc}
     */
    public function toText(): string
    {
        return $this->getData() ?? '';
    }

    /**
     * {@inheritdoc}
     */
    public function toWire(): string
    {
        return $this->data ?? '';
    }

    /**
     * {@inheritdoc}
     */
    public static function fromText(string $text): RdataInterface
    {
        return new self(null, $text);
    }

    /**
     * {@inheritdoc}
     */
    public static function fromWire(string $rdata): RdataInterface
    {
        return new self(null, $rdata);
    }
}
<commit_msg>Fix infinite recursion.<commit_after><?php

declare(strict_types=1);

/*
 * This file is part of Badcow DNS Library.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace Badcow\DNS\Rdata;

/**
 * Used to create RData of types that have not yet been implemented in the library.
 */
class PolymorphicRdata implements RdataInterface
{
    /**
     * The RData type.
     *
     * @var string
     */
    private $type;

    /**
     * @var string|null
     */
    private $data;

    /**
     * @var int
     */
    private $typeCode = 0;

    /**
     * PolymorphicRdata constructor.
     *
     * @param string|null $type
     * @param string|null $data
     */
    public function __construct(?string $type = null, ?string $data = null)
    {
        if (null !== $type) {
            $this->setType($type);
        }

        if (null !== $data) {
            $this->setData($data);
        }
    }

    /**
     * @param string $type
     */
    public function setType(string $type): void
    {
        try {
            $this->typeCode = Types::getTypeCode($type);
        } catch (UnsupportedTypeException $e) {
            $this->typeCode = 0;
        }
        $this->type = $type;
    }

    /**
     * {@inheritdoc}
     */
    public function getType(): string
    {
        return $this->type;
    }

    /**
     * @param int $typeCode
     */
    public function setTypeCode(int $typeCode): void
    {
        $this->typeCode = $typeCode;
    }

    /**
     * {@inheritdoc}
     */
    public function getTypeCode(): int
    {
        return $this->typeCode;
    }

    /**
     * @param string $data
     */
    public function setData(string $data): void
    {
        $this->data = $data;
    }

    /**
     * @return string|null
     */
    public function getData(): ?string
    {
        return $this->data;
    }

    /**
     * {@inheritdoc}
     */
    public function toText(): string
    {
        return $this->getData() ?? '';
    }

    /**
     * {@inheritdoc}
     */
    public function toWire(): string
    {
        return $this->data ?? '';
    }

    /**
     * {@inheritdoc}
     */
    public static function fromText(string $text): RdataInterface
    {
        return new self(null, $text);
    }

    /**
     * {@inheritdoc}
     */
    public static function fromWire(string $rdata): RdataInterface
    {
        return new self(null, $rdata);
    }
}

{'fraction_non_alphanumeric': 0.14106776180698152, 'fraction_numerical': 0.001026694045174538, 'mean_word_length': 1.7242729306487696, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 32, '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': '793029', 'n_tokens_mistral': 1521, 'n_tokens_neox': 1487, 'n_words': 369}