Zend\Ldap\Converter is a collection of useful LDAP related conversion functions.

category Zend
package Zend_Ldap

 Methods

Converts all ASCII chars < 32 to "\HEX"

ascToHex32(string $string) : string

see \Zend\Ldap\Converter\Net_LDAP2_Util::asc2hex32()
link http://pear.php.net/package/Net_LDAP2
author Benedikt Hallinger

Parameters

$string

string

String to convert

Returns

string

Convert an LDAP-compatible value to a corresponding PHP-value.

fromLdap(string $value, int $type, bool $dateTimeAsUtc) : mixed

By setting the $type-parameter the conversion of a certain type can be forced.

see \Zend\Ldap\Converter\Converter::STANDARD
see \Zend\Ldap\Converter\Converter::BOOLEAN
see \Zend\Ldap\Converter\Converter::GENERALIZED_TIME

Parameters

$value

string

The value to convert

$type

int

The conversion type to use

$dateTimeAsUtc

bool

Return DateTime values in UTC timezone

Returns

mixed

Convert an LDAP-compatible boolean value into a PHP-compatible one

fromLdapBoolean(string $value) : bool

Parameters

$value

string

The value to convert

Exceptions

\Zend\Ldap\Converter\Exception\InvalidArgumentException

Returns

bool

Convert an LDAP-Generalized-Time-entry into a DateTime-Object

fromLdapDateTime(string $date, bool $asUtc) : \DateTime

CAVEAT: The DateTime-Object returned will always be set to UTC-Timezone.

Parameters

$date

string

The generalized-Time

$asUtc

bool

Return the DateTime with UTC timezone

Exceptions

\Zend\Ldap\Converter\Exception\InvalidArgumentException if a non-parseable-format is given

Returns

Unserialize a serialized value to return the corresponding object

fromLdapUnserialize(string $value) : mixed

Parameters

$value

string

The value to convert

Exceptions

\Zend\Ldap\Converter\Exception\UnexpectedValueException

Returns

mixed

Converts all Hex expressions ("\HEX") to their original ASCII characters

hex32ToAsc(string $string) : string

see \Zend\Ldap\Converter\Net_LDAP2_Util::hex2asc()
link http://pear.php.net/package/Net_LDAP2
author Benedikt Hallinger <beni@php.net>, heavily based on work from DavidSmith@byu.net

Parameters

$string

string

String to convert

Returns

string

Convert any value to an LDAP-compatible value.

toLdap(mixed $value, int $type) : string | null

By setting the $type-parameter the conversion of a certain type can be forced

todo write more tests

Parameters

$value

mixed

The value to convert

$type

int

The conversion type to use

Exceptions

\Zend\Ldap\Converter\Exception\ConverterException

Returns

stringnull

Convert a boolean value to an LDAP-compatible string

toLdapBoolean(bool | integer | string $value) : string

This converts a boolean value of TRUE, an integer-value of 1 and a case-insensitive string 'true' to an LDAP-compatible 'TRUE'. All other other values are converted to an LDAP-compatible 'FALSE'.

Parameters

$value

boolintegerstring

The boolean value to encode

Returns

string

Converts a date-entity to an LDAP-compatible date-string

toLdapDateTime(integer | string | \DateTime $date, bool $asUtc) : string

The date-entity $date can be either a timestamp, a DateTime Object, a string that is parseable by strtotime().

Parameters

$date

integerstring\DateTime

The date-entity

$asUtc

bool

Whether to return the LDAP-compatible date-string as UTC or as local value

Exceptions

\Zend\Ldap\Converter\Exception\InvalidArgumentException

Returns

string

Serialize any value for storage in LDAP

toLdapSerialize(mixed $value) : string

Parameters

$value

mixed

The value to serialize

Returns

string

 Constants

 

BOOLEAN

BOOLEAN 

 

GENERALIZED_TIME

GENERALIZED_TIME 

 

STANDARD

STANDARD