You are here

public function SimpleLdapUser::__get in Simple LDAP 7.2

Same name and namespace in other branches
  1. 7 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 142
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':
      return $this->{$name};
    case 'dirty':
      return !empty($this->dirty);
    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,
      );
  }
}