You are here

public function SimpleLdapUser::__get in Simple LDAP 7

Same name and namespace in other branches
  1. 7.2 simple_ldap_user/SimpleLdapUser.class.php \SimpleLdapUser::__get()

Magic __get() function.

Parameters

string $name: Name of the variable to get.

Return value

mixed Returns the value of the requested variable, if allowed.

File

simple_ldap_user/SimpleLdapUser.class.php, line 94
Class defining a simple LDAP user.

Class

SimpleLdapUser
@file Class defining a simple LDAP user.

Code

public function __get($name) {
  switch ($name) {
    case 'attributes':
    case 'dn':
    case 'exists':
    case 'server':
    case 'mapObject':
      return $this->{$name};
    default:
      if (isset($this->attributes[$name])) {

        // Make sure 'count' is set accurately.
        if (!isset($this->attributes[$name]['count'])) {
          $this->attributes[$name]['count'] = count($this->attributes[$name]);
        }
        else {
          $this->attributes[$name]['count'] = count($this->attributes[$name]) - 1;
        }
        return $this->attributes[$name];
      }
      return array(
        'count' => 0,
      );
  }
}