Horde_Smtp::_getResponse PHP Méthode

_getResponse() protected méthode

Gets a line from the incoming stream and parses it.
protected _getResponse ( mixed $code, array $opts = [] ) : array
$code mixed Expected reply code(s) (integer or array).
$opts array Additional options:
  - error: (string) On error, 'logout' or 'reset'?
  - exception: (string) Throw an exception of this class on error.
Résultat array An array with the response text.
    protected function _getResponse($code, array $opts = array())
    {
        $opts = array_merge(array('error' => null, 'exception' => 'Horde_Smtp_Exception'), $opts);
        $text = array();
        while ($read = $this->_connection->read()) {
            $read = trim(rtrim($read, "\r\n"));
            $replycode = intval(substr($read, 0, 3));
            $text[] = ltrim(substr($read, 4));
            if ($read[3] != '-') {
                break;
            }
        }
        if (!is_array($code)) {
            $code = array($code);
        }
        if (in_array($replycode, $code)) {
            return $text;
        }
        /* Check for enhanced status codes (RFC 2034). */
        $details = reset($text);
        if (!is_null($this->_extensions) && $this->queryExtension('ENHANCEDSTATUSCODES')) {
            list($enhanced, $details) = explode(' ', $details, 2);
            if (!strpos($enhanced, '.')) {
                $details = $enhanced . ' ' . $details;
                $enhanced = null;
            }
        } else {
            $enhanced = null;
        }
        $e = new $opts['exception']($details);
        $e->details = $details;
        $e->setSmtpCode($replycode);
        if ($enhanced) {
            $e->setEnhancedSmtpCode($enhanced);
        }
        switch ($opts['error']) {
            case 'logout':
                $this->logout();
                break;
            case 'reset':
                /* RFC 3207: If we see 530, no need to send reset command. */
                if ($code != 530) {
                    $this->resetCmd();
                }
                break;
        }
        throw $e;
    }