Gets first character from file pointer
@param string $message
@param bool   $nl
@return string
320190
public static function readChar(string $message = '', bool $nl = false): string
    {
        $line = self::readln($message, $nl);

        return $line !== '' ? $line[0] : '';
    }
1260481
private function getMessageLineCount($message)
    {
        $messageLength = FormatterHelper::strlenWithoutDecoration($this->output->getFormatter(), $message);

        return ceil($messageLength / $this->getTerminalWidth());
    }
1031998
protected function getJsonPayload($message)
    {
        if (is_array($message) || $message instanceof JsonSerializable) {
            return json_encode($message);
        } elseif (method_exists($message, 'toJson')) {
            return $message->toJson();
        } elseif (method_exists($message, 'toArray')) {
            return json_encode($message->toArray());
        } elseif (is_string($message) && is_array(json_decode($message, true))) {
            return $message;
        }
    }
557871
public function logMessage($message, $level = 0) {
        $this->getLogFile();
        if (!flock($this->_fp, LOCK_EX)) {
            throw new LoggerFileException('Can\'t obtain file lock for: ');
        }
        $text = '[' . date("H:i:s") . ']' . $this->_levelNames[$level] . " " . $message . "\n"; // Log message
        if (fwrite($this->_fp, $text)) {
            flock($this->_fp, LOCK_UN);
            return true;
        } else {
            flock($this->_fp, LOCK_UN);
            throw new LoggerFileException('Can\'t write to logfile!');
        }
    }
1291895
public static function first($string, $length = 1, $encoding = null)
    {
        if ($string === '' || $length <= 0) {
            return '';
        }

        $encoding = $encoding === null ? mb_internal_encoding() : $encoding;

        return Mbstring::substr($string, 0, $length, $encoding);
    }
1226122
public static function padMessage($message)
    {
        $messageLen = strlen($message);
        $padLen = self::MAX_MESSAGE_LENGTH - $messageLen;

        return pack('n*', $padLen).str_pad($message, $padLen + $messageLen, chr(0), STR_PAD_LEFT);
    }
1186445
static function line($message = '', $newLine = 'after') {
		if($newLine == 'before' || $newLine == 'both') {
			echo PHP_EOL;
		}
		echo self::formatMessage("Error. $message", ['fg-red']);
		if($newLine == 'after' || $newLine == 'both') {
			echo PHP_EOL;
		}
	}
1128738
function getMessageSignature($message)
    {
        $pairs = $this->_makePairs($message);
        return base64_encode($this->sign($pairs));
    }
1040099
public function writeLinePrompt($message)
    {
        $this->writeLine();

        // write prompt badge
        $this->writeBadge('badge_pick', Color::RED);

        // output prompt
        $prompt = new Line(
            $this->translator->translate($message),
            false
        );

        $answer = $prompt->show();

        $this->writeLine();

        return $answer;
    }
1199456
public function writeln( LogMessage $message )
    {
        $timestamp = date("Y-m-d H:i:s");
        $level     = $message->getLevel();
        $tag       = $message->getTag();
        $msg       = $message->getMessage();
        $file      = $message->getFile();
        $line      = $message->getLine();

        $level_class_def = array(
                "T" => "level_t",
                "I" => "level_i",
                "D" => "level_d",
                "W" => "level_w",
                "E" => "level_e",
                "F" => "level_f",
            );

        $td_class = isset($level_class_def[$level]) ? $level_class_def[$level] : NULL;

        $html  = '<tr>' . PHP_EOL;
        $html .= '    <td class="' . $td_class . '"><div class="value center">' . $timestamp . '</div></td>' . PHP_EOL;
        $html .= '    <td class="' . $td_class . '"><div class="value center">' . $level . '</div></td>' . PHP_EOL;
        $html .= '    <td class="' . $td_class . '"><div class="value center">' . $tag . '</div></td>' . PHP_EOL;
        $html .= '    <td class="' . $td_class . '"><div class="value">' . $msg . '</div></td>' . PHP_EOL;
        $html .= '    <td class="' . $td_class . '"><div class="value">' . $file . '(' . $line . ')</div></td>' . PHP_EOL;
        $html .= '</tr>' . PHP_EOL;

        echo $html;
    }
1153724
public static function read($message = null, bool $nl = false, array $opts = []): string
    {
        if ($message) {
            self::write($message, $nl);
        }

        $opts = \array_merge([
            'length' => 1024,
            'stream' => \STDIN,
        ], $opts);

        return \file_get_contents($opts['stream'], $opts['length']);
    }
703183
private function _prepareMessage($message)
    {
        if (is_string($message) || is_numeric($message)) {
            return $message;
        }
        
        if (is_array($message)) {
            return json_encode($message, JSON_UNESCAPED_UNICODE);
        }
        
        return null;
    }
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);
    }
21301
public function lcfirst($str, $encoding = null)
	{
		$encoding or $encoding = $this->encoding;

		return function_exists('mb_strtolower')
			? mb_strtolower(mb_substr($str, 0, 1, $encoding), $encoding).
				mb_substr($str, 1, mb_strlen($str, $encoding), $encoding)
			: lcfirst($str);
	}
841613
public static function getStrWord(&$p, $l = false)
    {
        $r = static::binarySubstr($p, 0, 2);
        $p = static::binarySubstr($p, 2);
        if ($l) {
            $r = strrev($r);
        }
        return $r;
    }
246116
public function shouldMessageCaptureBeSkipped(string $message): bool
    {
        if (function_exists('fnmatch')) {
            foreach ($this->skipWildcard as $wildcard) {
                if (fnmatch($wildcard, $message)) {
                    return true;
                }
            }
        }
        if (in_array($message, $this->skipCapture, true)) {
            return true;
        }

        if (in_array($message, $this->skipCommand, true)) {
            return true;
        }
        return false;
    }
944995
public static function getLV(&$p, $l = 1, $nul = false, $lrev = false)
    {
        $s = static::b2i(mb_orig_substr($p, 0, $l), !!$lrev);
        $p = mb_orig_substr($p, $l);
        if ($s === 0) {
            return '';
        }
        $r = '';
        if (mb_orig_strlen($p) < $s) {
            Daemon::log('getLV error: buf length (' . mb_orig_strlen($p) . '): ' . Debug::exportBytes($p) . ', must be >= string length (' . $s . ")\n");
        } elseif ($nul) {
            $lastByte = mb_orig_substr($p, -1);
            if ($lastByte !== "\x00") {
                Daemon:
                log('getLV error: Wrong end of NUL-string (' . Debug::exportBytes($lastByte) . '), len ' . $s . "\n");
            } else {
                $d = $s - 1;
                if ($d < 0) {
                    $d = 0;
                }
                $r = mb_orig_substr($p, 0, $d);
                $p = mb_orig_substr($p, $s);
            }
        } else {
            $r = mb_orig_substr($p, 0, $s);
            $p = mb_orig_substr($p, $s);
        }
        return $r;
    }