LdapTools\Object\LdapObject::reset PHP Method

reset() public method

Resets the attribute, which effectively removes any values it may have.
public reset ( $attributes )
$attributes
    public function reset(...$attributes)
    {
        foreach ($attributes as $attribute) {
            if ($this->has($attribute)) {
                $attribute = $this->resolveAttributeName($attribute);
                unset($this->attributes[$attribute]);
            }
            $this->batches->add(new Batch(Batch::TYPE['REMOVE_ALL'], $attribute));
        }
        return $this;
    }

Usage Example

 function it_should_convert_values_to_ldap_with_a_batch_modification($connection)
 {
     $ldapObject = new LdapObject(...$this->ldapObjectOpts);
     $ldapObject->set('disabled', true);
     $ldapObject->set('trustedForAllDelegation', true);
     $ldapObject->set('username', 'foo');
     $ldapObject->add('emailAddress', '*****@*****.**');
     $ldapObject->remove('phoneNumber', '555-5555');
     $ldapObject->reset('pager');
     $uacBatch = ['attrib' => 'userAccountControl', 'modtype' => LDAP_MODIFY_BATCH_REPLACE, 'values' => ["524802"]];
     $usernameBatch = ['attrib' => 'username', 'modtype' => LDAP_MODIFY_BATCH_REPLACE, 'values' => ["foo"]];
     $emailBatch = ['attrib' => 'emailAddress', 'modtype' => LDAP_MODIFY_BATCH_ADD, 'values' => ["*****@*****.**"]];
     $phoneBatch = ['attrib' => 'phoneNumber', 'modtype' => LDAP_MODIFY_BATCH_REMOVE, 'values' => ["555-5555"]];
     $pagerBatch = ['attrib' => 'pager', 'modtype' => LDAP_MODIFY_BATCH_REMOVE_ALL];
     $connection->execute(Argument::that(function ($operation) {
         return $operation->getFilter() == '(&(objectClass=*))' && $operation->getBaseDn() == 'cn=foo,dc=foo,dc=bar' && $operation->getAttributes() == ['userAccountControl'];
     }))->willReturn($this->expectedResult);
     $this->beConstructedWith($this->schema, $ldapObject->getBatchCollection(), AttributeConverterInterface::TYPE_MODIFY);
     $this->setLdapConnection($connection);
     $this->setDn('cn=foo,dc=foo,dc=bar');
     $this->toLdap()->getBatchArray()->shouldHaveCount(5);
     $this->toLdap()->getBatchArray()->shouldContain($uacBatch);
     $this->toLdap()->getBatchArray()->shouldContain($usernameBatch);
     $this->toLdap()->getBatchArray()->shouldContain($emailBatch);
     $this->toLdap()->getBatchArray()->shouldContain($phoneBatch);
     $this->toLdap()->getBatchArray()->shouldContain($pagerBatch);
 }
All Usage Examples Of LdapTools\Object\LdapObject::reset