<commit_before><?php

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

namespace Symfony\Component\Ldap;

/**
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Entry
{
    private $dn;
    private $attributes;
    private $lowerMap;

    public function __construct(string $dn, array $attributes = [])
    {
        $this->dn = $dn;
        $this->attributes = [];
        $this->lowerMap = [];

        foreach ($attributes as $key => $attribute) {
            $this->setAttribute($key, $attribute);
        }
    }

    /**
     * Returns the entry's DN.
     *
     * @return string
     */
    public function getDn()
    {
        return $this->dn;
    }

    /**
     * Returns whether an attribute exists.
     *
     * @param string $name          The name of the attribute
     * @param bool   $caseSensitive Whether the check should be case-sensitive
     *
     * @return bool
     */
    public function hasAttribute(string $name/* , bool $caseSensitive = true */)
    {
        $caseSensitive = 2 > \func_num_args() || true === func_get_arg(1);
        $attributeKey = $this->getAttributeKey($name, $caseSensitive);

        if (null === $attributeKey) {
            return false;
        }

        return isset($this->attributes[$attributeKey]);
    }

    /**
     * Returns a specific attribute's value.
     *
     * As LDAP can return multiple values for a single attribute,
     * this value is returned as an array.
     *
     * @param string $name          The name of the attribute
     * @param bool   $caseSensitive Whether the attribute name is case-sensitive
     *
     * @return array|null
     */
    public function getAttribute(string $name/* , bool $caseSensitive = true */)
    {
        $caseSensitive = 2 > \func_num_args() || true === func_get_arg(1);
        $attributeKey = $this->getAttributeKey($name, $caseSensitive);

        if (null === $attributeKey) {
            return null;
        }

        return $this->attributes[$attributeKey] ?? null;
    }

    /**
     * Returns the complete list of attributes.
     *
     * @return array
     */
    public function getAttributes()
    {
        return $this->attributes;
    }

    /**
     * Sets a value for the given attribute.
     */
    public function setAttribute(string $name, array $value)
    {
        $this->attributes[$name] = $value;
        $this->lowerMap[strtolower($name)] = $name;
    }

    /**
     * Removes a given attribute.
     */
    public function removeAttribute(string $name)
    {
        unset($this->attributes[$name]);
        unset($this->lowerMap[strtolower($name)]);
    }

    /**
     * Get the attribute key.
     *
     * @param string $name          The attribute name
     * @param bool   $caseSensitive Whether the attribute name is case-sensitive
     */
    private function getAttributeKey(string $name, bool $caseSensitive = true): ?string
    {
        if ($caseSensitive) {
            return $name;
        }

        return $this->lowerMap[strtolower($name)] ?? null;
    }
}
<commit_msg>Remove extra docblock<commit_after><?php

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

namespace Symfony\Component\Ldap;

/**
 * @author <NAME> <<EMAIL>>
 * @author <NAME> <<EMAIL>>
 */
class Entry
{
    private $dn;
    private $attributes;
    private $lowerMap;

    public function __construct(string $dn, array $attributes = [])
    {
        $this->dn = $dn;
        $this->attributes = [];
        $this->lowerMap = [];

        foreach ($attributes as $key => $attribute) {
            $this->setAttribute($key, $attribute);
        }
    }

    /**
     * Returns the entry's DN.
     *
     * @return string
     */
    public function getDn()
    {
        return $this->dn;
    }

    /**
     * Returns whether an attribute exists.
     *
     * @param string $name          The name of the attribute
     * @param bool   $caseSensitive Whether the check should be case-sensitive
     *
     * @return bool
     */
    public function hasAttribute(string $name/* , bool $caseSensitive = true */)
    {
        $caseSensitive = 2 > \func_num_args() || true === func_get_arg(1);
        $attributeKey = $this->getAttributeKey($name, $caseSensitive);

        if (null === $attributeKey) {
            return false;
        }

        return isset($this->attributes[$attributeKey]);
    }

    /**
     * Returns a specific attribute's value.
     *
     * As LDAP can return multiple values for a single attribute,
     * this value is returned as an array.
     *
     * @param string $name          The name of the attribute
     * @param bool   $caseSensitive Whether the attribute name is case-sensitive
     *
     * @return array|null
     */
    public function getAttribute(string $name/* , bool $caseSensitive = true */)
    {
        $caseSensitive = 2 > \func_num_args() || true === func_get_arg(1);
        $attributeKey = $this->getAttributeKey($name, $caseSensitive);

        if (null === $attributeKey) {
            return null;
        }

        return $this->attributes[$attributeKey] ?? null;
    }

    /**
     * Returns the complete list of attributes.
     *
     * @return array
     */
    public function getAttributes()
    {
        return $this->attributes;
    }

    /**
     * Sets a value for the given attribute.
     */
    public function setAttribute(string $name, array $value)
    {
        $this->attributes[$name] = $value;
        $this->lowerMap[strtolower($name)] = $name;
    }

    /**
     * Removes a given attribute.
     */
    public function removeAttribute(string $name)
    {
        unset($this->attributes[$name]);
        unset($this->lowerMap[strtolower($name)]);
    }

    private function getAttributeKey(string $name, bool $caseSensitive = true): ?string
    {
        if ($caseSensitive) {
            return $name;
        }

        return $this->lowerMap[strtolower($name)] ?? null;
    }
}

{'fraction_non_alphanumeric': 0.12717965125579908, 'fraction_numerical': 0.0012797952327627579, 'mean_word_length': 2.13855421686747, 'pattern_counts': {'":': 0, '<': 23, '<?xml version=': 0, '>': 57, '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': '3557142', 'n_tokens_mistral': 1805, 'n_tokens_neox': 1777, 'n_words': 501}