PHP Class Adldap\Models\Model

Inheritance: implements ArrayAcces\ArrayAccess, implements JsonSerializabl\JsonSerializable
Show file Open project: adldap2/adldap2

Public Properties

Property Type Description
$dateFormat string Default format is suited for MySQL timestamps.
$exists boolean Indicates if the model exists.

Protected Properties

Property Type Description
$attributes array Contains the models attributes.
$dn string The models distinguished name.
$modifications array Contains the models modifications.
$original array Contains the models original attributes.
$query Adldap\Query\Builder The current query builder instance.
$schema Adldap\Schemas\SchemaInterface The current LDAP attribute schema.
$timestampFormat string The format that is used to convert AD timestamps to unix timestamps.

Public Methods

Method Description
__construct ( array $attributes, Builder $builder ) Constructor.
__get ( mixed $key ) : boolean Dynamically retrieve attributes on the object.
__set ( mixed $key, mixed $value ) Dynamically set attributes on the object.
addModification ( BatchModification $modification ) Adds a modification to the models modifications array.
countAttributes ( ) : integer Returns the number of attributes inside the attributes property.
create ( ) : boolean Creates the entry in LDAP.
createAttribute ( string $attribute, mixed $value ) : boolean Creates an attribute on the current model.
delete ( ) : boolean Deletes the current entry.
deleteAttribute ( string $attribute ) : boolean Deletes an attribute on the current entry.
fill ( array $attributes = [] ) Fills the entry with the supplied attributes.
filterRawAttributes ( array $attributes = [], array | string $keys = ['count'] ) : array Filters the count key recursively from raw LDAP attributes.
getAttribute ( integer | string $key, integer | string $subKey = null ) : mixed Returns the models attribute with the specified key.
getAttributes ( ) : array Returns all of the models attributes.
getCommonName ( ) : string Returns the model's common name.
getDirty ( ) : array Get the attributes that have been changed since last sync.
getDistinguishedName ( ) : string | null Returns the model's distinguished name string.
getDn ( ) : string | null Returns the model's distinguished name string.
getDnBuilder ( ) : DistinguishedName Returns a DistinguishedName object for modifying the current models DN.
getFirstAttribute ( string $key ) : mixed Returns the first attribute by the specified key.
getModifications ( ) : array Sets and returns the models modifications.
getNewDnBuilder ( string $baseDn = '' ) : DistinguishedName Returns a new DistinguishedName object for building onto.
getOriginal ( ) : array Returns the models original attributes.
getQuery ( ) : Builder Returns the current query builder.
getSchema ( ) : Adldap\Schemas\SchemaInterface Returns the current model schema.
hasAttribute ( integer | string $key, integer | string $subKey = null ) : boolean Returns true / false if the specified attribute exists in the attributes array.
jsonSerialize ( ) : array Convert the object into something JSON serializable.
move ( string $rdn, string | null $newParentDn = null, boolean | true $deleteOldRdn = true ) : boolean Moves the current model to a new RDN and new parent.
newCollection ( mixed $items = [] ) : Collection Returns a new collection with the specified items.
newQuery ( ) : Builder Returns a new query builder instance.
offsetExists ( string $offset ) : boolean Determine if the given offset exists.
offsetGet ( string $offset ) : mixed Get the value for a given offset.
offsetSet ( string $offset, mixed $value ) : void Set the value at the given offset.
offsetUnset ( string $offset ) : void Unset the value at the given offset.
rename ( string $rdn ) : boolean Alias for the move method.
save ( ) : boolean Saves the changes to LDAP and returns the results.
setAttribute ( integer | string $key, mixed $value, integer | string $subKey = null ) Sets an attributes value by the specified key and sub-key.
setCommonName ( string $name ) Sets the model's common name.
setDistinguishedName ( string | DistinguishedName $dn ) Sets the model's distinguished name attribute.
setDn ( string $dn ) Sets the model's distinguished name attribute.
setFirstAttribute ( integer | string $key, mixed $value ) Sets the first attributes value by the specified key.
setModifications ( array $modifications = [] ) Sets the models modifications array.
setQuery ( Builder $builder ) Sets the current query builder.
setRawAttributes ( array $attributes = [] ) Sets the attributes property.
setSchema ( Adldap\Schemas\SchemaInterface $schema ) Sets the current model schema.
syncOriginal ( ) Synchronizes the models original attributes with the model's current attributes.
syncRaw ( ) : boolean Synchronizes the models attributes with the server values.
update ( ) : boolean Updates the model.
updateAttribute ( string $attribute, mixed $value ) : boolean Updates the specified attribute with the specified value.

Protected Methods

Method Description
convertStringToBool ( string $bool ) : null | boolean Converts the inserted string boolean to a PHP boolean.
normalizeAttributeKey ( string $key ) : string Returns a normalized attribute key.
originalIsNumericallyEquivalent ( string $key ) : boolean Determine if the new and old values for a given key are numerically equivalent.

Method Details

__construct() public method

Constructor.
public __construct ( array $attributes, Builder $builder )
$attributes array
$builder Adldap\Query\Builder

__get() public method

Dynamically retrieve attributes on the object.
public __get ( mixed $key ) : boolean
$key mixed
return boolean

__set() public method

Dynamically set attributes on the object.
public __set ( mixed $key, mixed $value )
$key mixed
$value mixed

addModification() public method

Adds a modification to the models modifications array.
public addModification ( BatchModification $modification )
$modification Adldap\Objects\BatchModification

convertStringToBool() protected method

Converts the inserted string boolean to a PHP boolean.
protected convertStringToBool ( string $bool ) : null | boolean
$bool string
return null | boolean

countAttributes() public method

Returns the number of attributes inside the attributes property.
public countAttributes ( ) : integer
return integer

create() public method

Creates the entry in LDAP.
public create ( ) : boolean
return boolean

createAttribute() public method

Creates an attribute on the current model.
public createAttribute ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

delete() public method

Deletes the current entry.
public delete ( ) : boolean
return boolean

deleteAttribute() public method

Deletes an attribute on the current entry.
public deleteAttribute ( string $attribute ) : boolean
$attribute string
return boolean

fill() public method

Fills the entry with the supplied attributes.
public fill ( array $attributes = [] )
$attributes array

filterRawAttributes() public method

Filters the count key recursively from raw LDAP attributes.
public filterRawAttributes ( array $attributes = [], array | string $keys = ['count'] ) : array
$attributes array
$keys array | string
return array

getAttribute() public method

If a sub-key is specified, it will try and retrieve it from the parent keys array.
public getAttribute ( integer | string $key, integer | string $subKey = null ) : mixed
$key integer | string
$subKey integer | string
return mixed

getAttributes() public method

Returns all of the models attributes.
public getAttributes ( ) : array
return array

getCommonName() public method

https://msdn.microsoft.com/en-us/library/ms675449(v=vs.85).aspx
public getCommonName ( ) : string
return string

getDirty() public method

Get the attributes that have been changed since last sync.
public getDirty ( ) : array
return array

getDistinguishedName() public method

https://msdn.microsoft.com/en-us/library/aa366101(v=vs.85).aspx
public getDistinguishedName ( ) : string | null
return string | null

getDn() public method

(Alias for getDistinguishedName()) https://msdn.microsoft.com/en-us/library/aa366101(v=vs.85).aspx
public getDn ( ) : string | null
return string | null

getDnBuilder() public method

Returns a DistinguishedName object for modifying the current models DN.
public getDnBuilder ( ) : DistinguishedName
return Adldap\Objects\DistinguishedName

getFirstAttribute() public method

Returns the first attribute by the specified key.
public getFirstAttribute ( string $key ) : mixed
$key string
return mixed

getModifications() public method

Sets and returns the models modifications.
public getModifications ( ) : array
return array

getNewDnBuilder() public method

Returns a new DistinguishedName object for building onto.
public getNewDnBuilder ( string $baseDn = '' ) : DistinguishedName
$baseDn string
return Adldap\Objects\DistinguishedName

getOriginal() public method

Returns the models original attributes.
public getOriginal ( ) : array
return array

getQuery() public method

Returns the current query builder.
public getQuery ( ) : Builder
return Adldap\Query\Builder

getSchema() public method

Returns the current model schema.
public getSchema ( ) : Adldap\Schemas\SchemaInterface
return Adldap\Schemas\SchemaInterface

hasAttribute() public method

Returns true / false if the specified attribute exists in the attributes array.
public hasAttribute ( integer | string $key, integer | string $subKey = null ) : boolean
$key integer | string
$subKey integer | string
return boolean

jsonSerialize() public method

Convert the object into something JSON serializable.
public jsonSerialize ( ) : array
return array

move() public method

Moves the current model to a new RDN and new parent.
public move ( string $rdn, string | null $newParentDn = null, boolean | true $deleteOldRdn = true ) : boolean
$rdn string
$newParentDn string | null
$deleteOldRdn boolean | true
return boolean

newCollection() public method

Returns a new collection with the specified items.
public newCollection ( mixed $items = [] ) : Collection
$items mixed
return Illuminate\Support\Collection

newQuery() public method

Returns a new query builder instance.
public newQuery ( ) : Builder
return Adldap\Query\Builder

normalizeAttributeKey() protected method

Returns a normalized attribute key.
protected normalizeAttributeKey ( string $key ) : string
$key string
return string

offsetExists() public method

Determine if the given offset exists.
public offsetExists ( string $offset ) : boolean
$offset string
return boolean

offsetGet() public method

Get the value for a given offset.
public offsetGet ( string $offset ) : mixed
$offset string
return mixed

offsetSet() public method

Set the value at the given offset.
public offsetSet ( string $offset, mixed $value ) : void
$offset string
$value mixed
return void

offsetUnset() public method

Unset the value at the given offset.
public offsetUnset ( string $offset ) : void
$offset string
return void

originalIsNumericallyEquivalent() protected method

Determine if the new and old values for a given key are numerically equivalent.
protected originalIsNumericallyEquivalent ( string $key ) : boolean
$key string
return boolean

rename() public method

Alias for the move method.
public rename ( string $rdn ) : boolean
$rdn string
return boolean

save() public method

Saves the changes to LDAP and returns the results.
public save ( ) : boolean
return boolean

setAttribute() public method

Sets an attributes value by the specified key and sub-key.
public setAttribute ( integer | string $key, mixed $value, integer | string $subKey = null )
$key integer | string
$value mixed
$subKey integer | string

setCommonName() public method

Sets the model's common name.
public setCommonName ( string $name )
$name string

setDistinguishedName() public method

Sets the model's distinguished name attribute.
public setDistinguishedName ( string | DistinguishedName $dn )
$dn string | Adldap\Objects\DistinguishedName

setDn() public method

(Alias for setDistinguishedName())
public setDn ( string $dn )
$dn string

setFirstAttribute() public method

Sets the first attributes value by the specified key.
public setFirstAttribute ( integer | string $key, mixed $value )
$key integer | string
$value mixed

setModifications() public method

Sets the models modifications array.
public setModifications ( array $modifications = [] )
$modifications array

setQuery() public method

Sets the current query builder.
public setQuery ( Builder $builder )
$builder Adldap\Query\Builder

setRawAttributes() public method

Sets the attributes property.
public setRawAttributes ( array $attributes = [] )
$attributes array

setSchema() public method

Sets the current model schema.
public setSchema ( Adldap\Schemas\SchemaInterface $schema )
$schema Adldap\Schemas\SchemaInterface

syncOriginal() public method

Synchronizes the models original attributes with the model's current attributes.
public syncOriginal ( )

syncRaw() public method

Synchronizes the models attributes with the server values.
public syncRaw ( ) : boolean
return boolean

update() public method

Updates the model.
public update ( ) : boolean
return boolean

updateAttribute() public method

Updates the specified attribute with the specified value.
public updateAttribute ( string $attribute, mixed $value ) : boolean
$attribute string
$value mixed
return boolean

Property Details

$attributes protected property

Contains the models attributes.
protected array $attributes
return array

$dateFormat public property

Default format is suited for MySQL timestamps.
public string $dateFormat
return string

$dn protected property

The models distinguished name.
protected string $dn
return string

$exists public property

Indicates if the model exists.
public bool $exists
return boolean

$modifications protected property

Contains the models modifications.
protected array $modifications
return array

$original protected property

Contains the models original attributes.
protected array $original
return array

$query protected property

The current query builder instance.
protected Builder,Adldap\Query $query
return Adldap\Query\Builder

$schema protected property

The current LDAP attribute schema.
protected SchemaInterface,Adldap\Schemas $schema
return Adldap\Schemas\SchemaInterface

$timestampFormat protected property

The format that is used to convert AD timestamps to unix timestamps.
protected string $timestampFormat
return string