*/ class DebugFormatterHelper extends Helper { private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default']; private $started = []; private $count = -1; /** * Starts a debug formatting session. * * @return string */ public function start(string $id, string $message, string $prefix = 'RUN') { $this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)]; return sprintf("%s %s %s\n", $this->getBorder($id), $prefix, $message); } /** * Adds progress to a formatting session. * * @return string */ public function progress( string $id, string $buffer, bool $error = false, string $prefix = 'OUT', string $errorPrefix = 'ERR', ) { $message = ''; if ($error) { if (isset($this->started[$id]['out'])) { $message .= "\n"; unset($this->started[$id]['out']); } if (!isset($this->started[$id]['err'])) { $message .= sprintf('%s %s ', $this->getBorder($id), $errorPrefix); $this->started[$id]['err'] = true; } $message .= str_replace("\n", sprintf("\n%s %s ", $this->getBorder($id), $errorPrefix), $buffer); } else { if (isset($this->started[$id]['err'])) { $message .= "\n"; unset($this->started[$id]['err']); } if (!isset($this->started[$id]['out'])) { $message .= sprintf('%s %s ', $this->getBorder($id), $prefix); $this->started[$id]['out'] = true; } $message .= str_replace("\n", sprintf("\n%s %s ", $this->getBorder($id), $prefix), $buffer); } return $message; } /** * Stops a formatting session. * * @return string */ public function stop(string $id, string $message, bool $successful, string $prefix = 'RES') { $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : ''; if ($successful) { return sprintf("%s%s %s %s\n", $trailingEOL, $this->getBorder($id), $prefix, $message); } $message = sprintf("%s%s %s %s\n", $trailingEOL, $this->getBorder($id), $prefix, $message); unset($this->started[$id]['out'], $this->started[$id]['err']); return $message; } private function getBorder(string $id): string { return sprintf(' ', self::COLORS[$this->started[$id]['border']]); } /** * {@inheritdoc} */ public function getName() { return 'debug_formatter'; } } __halt_compiler();----SIGNATURE:----tshgBZOm5Sdg3GOa3ofx0VFrWe+y+0/wG0h50vImeJPGLD8MzZI+An6jBEOzN8Qj6WfPWrbIZKyBa7ngBy+pCagLQd+adPY/U3n5UomusC88Qvfo8Y4DcJm8ET5v+P2113rwJ22UVYzmQc7JwA8DfTIGBAsRcKsr+iuTmP+DD5eRtyxDbO9gsJRpbCVQOWKgjoVReT5H4azTAsCNh0a92lAHZi1G3cUlAnW78r7xAAxON4jwdV+ucW7/FQySY2rdOdX03zRdjKE3jt99Zbo/qXybeYYk+JZq5PsJ6+xIIZOO1NWO/Gb5P/MvBiN6W45PDk5zXAn0O0xU0CG/KWFaDZaVAzJxNarIBLYA3VaxNGnLV1IGu5Sa+xXFGjBnK/5zgs17oKTWjq//TwccA5ipBAfVr0LhoPQnEgii/2DhpjJZXghHtwBeciWJRzzB9xIlNaI411kUTbhBeTNLsuI+BZB1ZxKvdbDMyDARHYnQj1geGwagESqQvy1h2uuw8jFfnUgt+y3ASpKWCAYVz8xxjP4OXImCU8bE0dWJ66JZMJS2gPKiiElxIyxbpnAnMpq4Kb+LoSKrnJ5oA8v+YKQzmdfu8gXf9CHkT0vldDjHvFG7ZE13FvbxCrWQqcxBnnVsa8QLNkd3sx8qE4+tll9WYNNBoPWbvhJzy2krrrlCh2U=----ATTACHMENT:----NjAyMjgzMzkwNTI5NTY4NSA1NTc3MjkxODE3MTc5MTMgOTEzOTkxNTgyNDg2NDY1Mw==