So I have the following code, which connects and then binds to an LDAP server.The question is in the first method.  public function getUsers() // This is the method in question  {    if( $this->connect()->bind() ) {      ldap_query(self::$connection) // Here, should it be aware that class succesfully loaded         // the connection, or should the bind() method return the resource?    }  }  public function connect()  {    self::$connection = ldap_connect($this->host);    if( ! self::$connection ) {      throw new \CHttpException(503, 'No se puede establecer una conexin con el servidor '.$this->host);    }    foreach( $this->options as $option => $value ) {      ldap_set_option(self::$connection, constant($option), $value);    }    return $this;  }  public function bind()  {    $ldapbind = ldap_bind(self::$connection, $this->username.'@'.$this->domain, $this->password);    if( ! $ldapbind ) {      throw new \CHttpException(503, 'No se puede enlazar con el servidor: '.ldap_error(self::$connection));    }    return true;  }
Should a method in a class be aware that the class has loaded a variable?
object oriented;code quality
Classes (or objects as instances of classes) create a local scope where member variables serve as global within the boundaries of this scope. This is intentional, so it is perfectly ok if one member function initializes a member variable and a second makes use of the fact the first function finished successfully without an exception.So in your case: if bind() initializes  $ldapbind (and does not throw an exception), there is no reason to return $ldapbind. getUsers can just safely assume $ldapbind to be initialized.