LdapTools\Object\LdapObject::get PHP Method

get() public method

Get the value of an attribute. An attribute with multiple values will return an array of values.
public get ( string $attribute ) : mixed
$attribute string
return mixed
    public function get($attribute)
    {
        if ($this->has($attribute)) {
            return MBString::array_change_key_case($this->attributes)[MBString::strtolower($attribute)];
        } else {
            throw new InvalidArgumentException(sprintf('Attribute "%s" is not defined for this LDAP object.', $attribute));
        }
    }

Usage Example

 function it_should_delete_a_ldap_object(LdapConnectionInterface $connection)
 {
     $domainConfig = new DomainConfiguration('example.local');
     $connection->getConfig()->willReturn($domainConfig);
     $this->beConstructedWith(new Configuration(), $connection);
     $ldapObject = new LdapObject(['dn' => 'cn=foo,dc=foo,dc=bar'], 'user');
     $operation = new DeleteOperation($ldapObject->get('dn'));
     $connection->execute($operation)->shouldBeCalled();
     $this->delete($ldapObject);
     $operation->addControl((new LdapControl(LdapControlType::SUB_TREE_DELETE))->setCriticality(true));
     $connection->execute($operation)->shouldBeCalled();
     $this->delete($ldapObject, true);
 }
All Usage Examples Of LdapTools\Object\LdapObject::get