Processes the indent level for the messages

@param string $message

@return integer The indent difference AFTER this message
167875
protected static function _processMessage( &$message )
    {
        $_newIndent = 0;

        foreach ( static::$_indentTokens as $_key => $_token )
        {
            if ( $_token == substr( $message, 0, $_length = strlen( $_token ) ) )
            {
                $_newIndent = ( false === $_key ? -1 : 1 );
                $message = substr( $message, $_length );
            }
        }

        return $_newIndent;
    }
760532
public function err( $message )
	{
		$ex = new Exception();
		echo $ex->getTraceAsString();

		if ( ! $this->log ) return;
		return $this->log->err( $message );
	}
816094
protected function getDecoratedMessage($message, $params = [])
    {
        $result = '';
        $prefix = '';
        foreach ($params as $option => $value) {
            if ($value) {
                $result .= $prefix . $this->decorations[$option][$value];
                $prefix = ';';
            }
        }

        if ($prefix) {
            $message = 'm' . $message;
        }

        return $result . $message;
    }
313221
public function a($message) {
        return isset($this->messages[$message]) ? $this->messages[$message] : $message;
    }
434746
public function format($message, array $references = array())
    {
        // sort references by start indice
        // for testing issue we need to add @
        // @see https://github.com/phpspec/prophecy/issues/161
        @uasort($references, function ($a, $b) {
            return $a->getStartIndice() > $b->getStartIndice();
        });

        $messageParts = $this->buildMessageParts($message, $references);

        // build message
        $formattedMessageParts = array();

        foreach ($messageParts as $messagePart) {
            if (is_null($messagePart)) {
                continue;
            }

            $formattedMessageParts[] = $this->formatMessagePart($messagePart);
        }

        return implode($formattedMessageParts);
    }
840835
public static function indent($xml) {
      $cnt = 0;
      $d = 0;
      $t = 0;
      $c = 0;
      while ($cnt != strlen($xml)) {
        $ch = substr($xml, $cnt, 1);
        $ch2 = substr($xml, $cnt, 2);
        $lch = substr($xml, strlen($xml) - 1, 1);
        $f = strlen($xml);
        $a = strlen($xml);

          if ($ch == "<" && $ch2 != "</" && $cnt != "0") {
            $n = "\n";
              for($i = 0; $i <= ($t - $c); $i ++) {
                $n .= "\t";
              }

            $pre = substr($xml, 0, $cnt);
            $af = substr($xml, $cnt, (max(strlen($xml), $cnt) - min(strlen($xml), $cnt)));
            $xml = $pre . $n . $af;

            $a = strlen($xml);
            $d ++;
            $t ++;
          }

          if ($ch2 == "</") {
            $n = "\n";
            for($i = 0; $i <= ($t - $c) - 1; $i ++) {
              $n .= "\t";
            }

            $pre = substr($xml, 0, $cnt);
            $af = substr($xml, $cnt, (max(strlen($xml), $cnt) - min(strlen($xml), $cnt)));
            $xml = $pre . $n . $af;

            $a = strlen($xml);
            $c ++;
          }

          $cnt += ($a - $f) > 0 ? ($a-$f)+1:1;         
      }

      return $xml;
    }
939652
public function get($message)
    {
        if (isset($this->messages[$message])) {
            $message = $this->messages[$message][0];
        }
        return $this->replacePlaceholders($message, array_slice(func_get_args(), 1));
    }
713440
public function translate($message)
    {
        if (isset($this->translations[$message])) {
            return $this->translations[$message];
        } else {
            return $message;
        }
    }
1022068
private function getMessage(string $message): string
    {
        /** @var FormatterFactoryInterface $factory */
        $factory   = $this->getContainer()->get(FormatterFactoryInterface::class);
        $formatter = $factory->createFormatter(Messages::NAMESPACE_NAME);
        $result    = $formatter->formatMessage($message);

        return $result;
    }
217976
public function markAsDisappeared($message = null)
    {
        if (!is_null($message)) {
            $this->setMessages($message);
        }
        $this
            ->setStatus(self::STATUS_DISAPPEARED)
            ->setFinishedAt($this->getLastSeen())
            ->save();

        $this->log(sprintf('Job "%s" (id: %s) disappeared. Message: %s', $this->getJobCode(), $this->getId(), $message));
    }
61765
public function commitMsgHook($message) {
    $this->say('Validating commit message syntax...');
    $pattern = $this->getConfigValue('git.commit-msg.pattern');
    $help_description = $this->getConfigValue('git.commit-msg.help_description');
    $example = $this->getConfigValue('git.commit-msg.example');
    $this->logger->debug("Validing commit message with regex <comment>$pattern</comment>.");
    if (!preg_match($pattern, $message)) {
      $this->logger->error("Invalid commit message!");
      $this->say("Commit messages must conform to the regex $pattern");
      if (!empty($help_description)) {
        $this->say("$help_description");
      }
      if (!empty($example)) {
        $this->say("Example: $example");
      }
      $this->logger->notice("To disable or customize Git hooks, see http://blt.rtfd.io/en/latest/readme/extending-blt/#git-hooks");

      return 1;
    }

    return 0;
  }
1038897
public function gettext($message) {
		$args = func_get_args();
		$methodArgsNumber = 1;
		$message = $this->callMethodAndSprintf(__FUNCTION__, $args, $methodArgsNumber);
		return $message;
	}
655588
private function _gzdecode($message)
    {
        $messageLength  = strlen($message);
        $isDebugEnabled = $this->_logger->isHandling(ehough_epilog_Logger::DEBUG);

        /* make sure this is actually gzipped */
        if ($messageLength < 18 || strcmp(substr($message, 0, 2), "\x1f\x8b")) {

            if ($isDebugEnabled) {

                $this->_logger->debug('Not in GZIP format.');
            }

            return false;
        }

        /* grab the compression method and flags */
        $compressionMethod = ord(substr($message, 2, 1));
        $compressionFlags  = ord(substr($message, 3, 1));

        if ($compressionFlags & 31 != $compressionFlags) {

            if ($isDebugEnabled) {

                $this->_logger->debug('Reserved bits not allowed.');
            }

            return false;
        }

        /* NOTE: $mtime may be negative (PHP integer limitations) */
        $mtime        = unpack('V', substr($message, 4, 4));
        $mtime        = $mtime[1];
        $xfl          = substr($message, 8, 1);
        $os           = substr($message, 8, 1);
        $headerLength = 10;
        $extraLength  = 0;
        $extra        = '';

        if ($compressionFlags & 4) {

            /* 2-byte length prefixed EXTRA data in header */
            if ($messageLength - $headerLength - 2 < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('2-byte length prefixed EXTRA data in header');
                }

                return false;
            }

            $extraLength = unpack('v', substr($message, 8, 2));
            $extraLength = $extraLength[1];

            if ($messageLength - $headerLength - 2 - $extraLength < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('Invalid extra length');
                }

                return false;
            }

            $extra         = substr($message, 10, $extraLength);
            $headerLength += 2 + $extraLength;
        }

        $filenameLength = 0;
        $filename       = '';

        /* If FNAME is set, an original file name is present, terminated by a zero byte. */
        if ($compressionFlags & 8) {

            if ($messageLength - $headerLength - 1 < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('C-Style string');
                }

                return false;
            }

            $filenameLength = strpos(substr($message, $headerLength), chr(0));

            if ($filenameLength === false || $messageLength - $headerLength - $filenameLength - 1 < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('Invalid filename length');
                }

                return false;
            }

            $filename      = substr($message, $headerLength, $filenameLength);
            $headerLength += $filenameLength + 1;
        }

        $commentlen = 0;
        $comment    = '';

        /* If FCOMMENT is set, a zero-terminated file comment is present */
        if ($compressionFlags & 16) {

            if ($messageLength - $headerLength - 1 < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('C-Style string COMMENT data in header');
                }

                return false;
            }

            $commentlen = strpos(substr($message, $headerLength), chr(0));

            if ($commentlen === false || $messageLength - $headerLength - $commentlen - 1 < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('Invalid comment length');
                }

                return false;
            }

            $comment       = substr($message, $headerLength, $commentlen);
            $headerLength += $commentlen + 1;
        }

        $headercrc = '';

        /* If FHCRC is set, a CRC16 for the gzip header is present, immediately before the compressed data */
        if ($compressionFlags & 2) {

            if ($messageLength - $headerLength - 2 < 8) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('2-bytes (lowest order) of CRC32 on header present');
                }

                return false;
            }

            $calccrc   = crc32(substr($message, 0, $headerLength)) & 0xffff;
            $headercrc = unpack('v', substr($message, $headerLength, 2));
            $headercrc = $headercrc[1];

            if ($headercrc != $calccrc) {

                if ($isDebugEnabled) {

                    $this->_logger->debug('Header checksum failed.');
                }

            }

            $headerLength += 2;
        }

        $datacrc = unpack('V', substr($message, -8, 4));
        $datacrc = sprintf('%u', $datacrc[1] & 0xFFFFFFFF);
        $isize   = unpack('V', substr($message, -4));
        $isize   = $isize[1];

        $bodyLength = $messageLength - $headerLength - 8;

        if ($bodyLength < 1) {

            if ($isDebugEnabled) {

                $this->_logger->debug('Negative body length');
            }

            return false;
        }

        $compressedBody = substr($message, $headerLength, $bodyLength);
        $decompressed   = '';

        if ($bodyLength > 0) {

            switch ($compressionMethod) {

                case 8:
                    // Currently the only supported compression method:
                    $decompressed = gzinflate($compressedBody, null);
                    break;

                default:

                    if ($isDebugEnabled) {

                        $this->_logger->debug('Unknown compression method.');
                    }

                    return false;
            }
        }

        $crc   = sprintf("%u", crc32($decompressed));
        $crcOK = $crc == $datacrc;
        $lenOK = $isize == strlen($decompressed);

        if (!$lenOK || !$crcOK) {

            return false;
        }

        return $decompressed;
    }
594688
private function tryResolveErrorReason(string $message): string
    {
        $key = $this->responseParser->parse($message);

        if ($key === 'invalid_phone') {
            return ErrorReasons::INVALID_PHONE_NUMBER;
        }

        return ErrorReasons::UNKNOWN;
    }
210723
private function summarize($message)
    {
        $message = ltrim($message, "\n");
        if ($newLinePos = strpos($message, "\n")) {
            $message = substr($message, 0, $newLinePos);
        }

        return rtrim($message);
    }
229605
protected function buildMessage($message, $indent = '')
    {
        switch (true) {
            case is_array($message):
                $this->buildArrayMessage($message, $indent);
                break;

            case method_exists($message, '__toString'):
            case is_string($message):
                $this->message = $message . PHP_EOL;
                break;

            default:
                throw new InvalidArgumentException(
                    'Incorrect message type. Must be string, array or object with __toString method.'
                );
                break;
        }

        return $this;
    }
1235031
public static function createFromRaw($message)
    {
        $eventStart = strpos($message, 'Event: ') + 7;
        $eventEnd = strpos($message, Message::EOL, $eventStart);
        if ($eventEnd === false) {
            $eventEnd = strlen($message);
        }
        $name = substr($message, $eventStart, $eventEnd - $eventStart);
        $parts = explode('_', $name);
        $totalParts = count($parts);
        for ($i = 0; $i < $totalParts; $i++) {
            $parts[$i] = ucfirst($parts[$i]);
        }
        $name = implode($parts, '');
        $className = '\\PAMI\\Message\\Event\\' . $name . 'Event';
        if (class_exists($className, true)) {
            return new $className($message);
        }
        return new UnknownEvent($message);
    }