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

namespace yswery\DNS;

class ResourceRecord
{
    /**
     * @var string
     */
    private $name;

    /**
     * @var int
     */
    private $type;

    /**
     * @var int
     */
    private $ttl;

    /**
     * @var string|array
     */
    private $rdata;

    /**
     * @var int
     */
    private $class = ClassEnum::INTERNET;

    /**
     * @var bool
     */
    private $question = false;

    /**
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return ResourceRecord
     */
    public function setName($name)
    {
        $this->name = $name;
        return $this;
    }

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

    /**
     * @param int $type
     * @return ResourceRecord
     */
    public function setType($type)
    {
        $this->type = $type;
        return $this;
    }

    /**
     * @return int
     */
    public function getTtl()
    {
        return $this->ttl;
    }

    /**
     * @param int $ttl
     * @return ResourceRecord
     */
    public function setTtl($ttl)
    {
        $this->ttl = $ttl;
        return $this;
    }

    /**
     * @return array|string
     */
    public function getRdata()
    {
        return $this->rdata;
    }

    /**
     * @param array|string $rdata
     * @return ResourceRecord
     */
    public function setRdata($rdata)
    {
        $this->rdata = $rdata;
        return $this;
    }

    /**
     * @return int
     */
    public function getClass()
    {
        return $this->class;
    }

    /**
     * @param int $class
     * @return ResourceRecord
     */
    public function setClass($class)
    {
        $this->class = $class;
        return $this;
    }

    /**
     * @return bool
     */
    public function isQuestion()
    {
        return $this->question;
    }

    /**
     * @param bool $question
     * @return ResourceRecord
     */
    public function setQuestion($question)
    {
        $this->question = (bool) $question;
        return $this;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        if (is_array($this->rdata)) {
            $rdata = '(';
            foreach ($this->rdata as $key => $value) {
                $rdata .= $key . ': ' . $value . ', ';
            }
            $rdata = rtrim($rdata, ', ') . ')';
        } else {
            $rdata = $this->rdata;
        }

        return sprintf(
            '%s %s %s %s %s',
            $this->name,
            RecordTypeEnum::getName($this->type),
            ClassEnum::getName($this->class),
            $this->ttl,
            $rdata
        );
    }
}
<commit_msg>Resolved issues in ResourceRecord class reported by phpstorm<commit_after><?php
/*
 * This file is part of PHP DNS Server.
 *
 * (c) <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

namespace yswery\DNS;

class ResourceRecord
{
    /**
     * @var string
     */
    private $name;

    /**
     * @var int
     */
    private $type;

    /**
     * @var int
     */
    private $ttl;

    /**
     * @var string|array
     */
    private $rdata;

    /**
     * @var int
     */
    private $class = ClassEnum::INTERNET;

    /**
     * @var bool
     */
    private $question = false;

    /**
     * @return string
     */
    public function getName(): string
    {
        return $this->name;
    }

    /**
     * @param string $name
     * @return ResourceRecord
     */
    public function setName($name): ResourceRecord
    {
        $this->name = $name;
        return $this;
    }

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

    /**
     * @param int $type
     * @return ResourceRecord
     */
    public function setType($type): ResourceRecord
    {
        $this->type = $type;
        return $this;
    }

    /**
     * @return int
     */
    public function getTtl(): int
    {
        return $this->ttl;
    }

    /**
     * @param int $ttl
     * @return ResourceRecord
     */
    public function setTtl($ttl): ResourceRecord
    {
        $this->ttl = $ttl;
        return $this;
    }

    /**
     * @return array|string
     */
    public function getRdata()
    {
        return $this->rdata;
    }

    /**
     * @param array|string $rdata
     * @return ResourceRecord
     */
    public function setRdata($rdata): ResourceRecord
    {
        $this->rdata = $rdata;
        return $this;
    }

    /**
     * @return int
     */
    public function getClass(): int
    {
        return $this->class;
    }

    /**
     * @param int $class
     * @return ResourceRecord
     */
    public function setClass($class): ResourceRecord
    {
        $this->class = $class;
        return $this;
    }

    /**
     * @return bool
     */
    public function isQuestion(): bool
    {
        return $this->question;
    }

    /**
     * @param bool $question
     * @return ResourceRecord
     */
    public function setQuestion($question): ResourceRecord
    {
        $this->question = (bool) $question;
        return $this;
    }

    /**
     * @return string
     */
    public function __toString()
    {
        if (\is_array($this->rdata)) {
            $rdata = '(';
            foreach ($this->rdata as $key => $value) {
                $rdata .= $key . ': ' . $value . ', ';
            }
            $rdata = rtrim($rdata, ', ') . ')';
        } else {
            $rdata = $this->rdata;
        }

        return sprintf(
            '%s %s %s %s %s',
            $this->name,
            RecordTypeEnum::getName($this->type),
            ClassEnum::getName($this->class),
            $this->ttl,
            $rdata
        );
    }
}

{'fraction_non_alphanumeric': 0.1427871262865545, 'fraction_numerical': 0.0, 'mean_word_length': 1.4429369513168395, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 49, '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': '2094605', 'n_tokens_mistral': 1919, 'n_tokens_neox': 1877, 'n_words': 436}