This repository has been archived on 2023-08-20. You can view files and clone it, but cannot push or open issues or pull requests.
symfony/src/Symfony/Component/Ldap/Entry.php

95 lines
1.8 KiB
PHP
Raw Normal View History

<?php
/*
* This file is part of the Symfony package.
*
* (c) Fabien Potencier <fabien@symfony.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Symfony\Component\Ldap;
/**
* @author Charles Sarrazin <charles@sarraz.in>
*/
class Entry
{
private $dn;
private $attributes;
2019-01-16 18:24:45 +00:00
public function __construct(string $dn, array $attributes = [])
{
$this->dn = $dn;
$this->attributes = $attributes;
}
/**
* Returns the entry's DN.
*
* @return string
*/
public function getDn()
{
return $this->dn;
}
/**
* Returns whether an attribute exists.
*
2018-11-20 16:10:26 +00:00
* @param string $name The name of the attribute
*
* @return bool
*/
public function hasAttribute($name)
{
return isset($this->attributes[$name]);
}
/**
* Returns a specific attribute's value.
*
* As LDAP can return multiple values for a single attribute,
* this value is returned as an array.
*
2018-11-20 16:10:26 +00:00
* @param string $name The name of the attribute
*
* @return array|null
*/
public function getAttribute($name)
{
return isset($this->attributes[$name]) ? $this->attributes[$name] : null;
}
/**
* Returns the complete list of attributes.
*
* @return array
*/
public function getAttributes()
{
return $this->attributes;
}
/**
* Sets a value for the given attribute.
*
* @param string $name
*/
public function setAttribute($name, array $value)
{
$this->attributes[$name] = $value;
}
/**
* Removes a given attribute.
*
* @param string $name
*/
public function removeAttribute($name)
{
unset($this->attributes[$name]);
}
}