PluginProbe ʕ •ᴥ•ʔ
Matomo Analytics – Powerful, Privacy-First Insights for WordPress / 5.8.2
Matomo Analytics – Powerful, Privacy-First Insights for WordPress v5.8.2
5.11.1 5.11.0 5.10.2 5.10.1 trunk 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.1.0 1.1.1 1.1.2 1.1.3 1.2.0 1.3.0 1.3.1 1.3.2 4.0.0 4.0.1 4.0.2 4.0.3 4.0.4 4.1.0 4.1.1 4.1.2 4.1.3 4.10.0 4.11.0 4.12.0 4.13.0 4.13.2 4.13.3 4.13.4 4.13.5 4.14.0 4.14.1 4.14.2 4.15.0 4.15.1 4.15.2 4.15.3 4.2.0 4.3.0 4.3.1 4.4.1 4.4.2 4.5.0 4.6.0 5.0.1 5.0.2 5.0.3 5.0.4 5.0.5 5.0.6 5.0.7 5.0.8 5.1.0 5.1.1 5.1.2 5.1.3 5.1.4 5.1.5 5.1.6 5.1.7 5.10.0 5.2.0 5.2.1 5.2.2 5.3.0 5.3.1 5.3.2 5.3.3 5.6.0 5.6.1 5.7.0 5.7.1 5.8.0 5.8.1 5.8.2
matomo / app / vendor / prefixed / symfony / console / Helper / DebugFormatterHelper.php
matomo / app / vendor / prefixed / symfony / console / Helper Last commit date
DebugFormatterHelper.php 1 year ago DescriptorHelper.php 1 year ago Dumper.php 1 year ago FormatterHelper.php 1 year ago Helper.php 1 year ago HelperInterface.php 2 years ago HelperSet.php 2 years ago InputAwareHelper.php 2 years ago ProcessHelper.php 2 years ago ProgressBar.php 1 year ago ProgressIndicator.php 1 year ago QuestionHelper.php 1 year ago SymfonyQuestionHelper.php 1 year ago Table.php 1 year ago TableCell.php 2 years ago TableCellStyle.php 2 years ago TableRows.php 2 years ago TableSeparator.php 2 years ago TableStyle.php 1 year ago
DebugFormatterHelper.php
93 lines
1 <?php
2
3 /*
4 * This file is part of the Symfony package.
5 *
6 * (c) Fabien Potencier <fabien@symfony.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11 namespace Matomo\Dependencies\Symfony\Component\Console\Helper;
12
13 /**
14 * Helps outputting debug information when running an external program from a command.
15 *
16 * An external program can be a Process, an HTTP request, or anything else.
17 *
18 * @author Fabien Potencier <fabien@symfony.com>
19 */
20 class DebugFormatterHelper extends Helper
21 {
22 private const COLORS = ['black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white', 'default'];
23 private $started = [];
24 private $count = -1;
25 /**
26 * Starts a debug formatting session.
27 *
28 * @return string
29 */
30 public function start(string $id, string $message, string $prefix = 'RUN')
31 {
32 $this->started[$id] = ['border' => ++$this->count % \count(self::COLORS)];
33 return sprintf("%s<bg=blue;fg=white> %s </> <fg=blue>%s</>\n", $this->getBorder($id), $prefix, $message);
34 }
35 /**
36 * Adds progress to a formatting session.
37 *
38 * @return string
39 */
40 public function progress(string $id, string $buffer, bool $error = \false, string $prefix = 'OUT', string $errorPrefix = 'ERR')
41 {
42 $message = '';
43 if ($error) {
44 if (isset($this->started[$id]['out'])) {
45 $message .= "\n";
46 unset($this->started[$id]['out']);
47 }
48 if (!isset($this->started[$id]['err'])) {
49 $message .= sprintf('%s<bg=red;fg=white> %s </> ', $this->getBorder($id), $errorPrefix);
50 $this->started[$id]['err'] = \true;
51 }
52 $message .= str_replace("\n", sprintf("\n%s<bg=red;fg=white> %s </> ", $this->getBorder($id), $errorPrefix), $buffer);
53 } else {
54 if (isset($this->started[$id]['err'])) {
55 $message .= "\n";
56 unset($this->started[$id]['err']);
57 }
58 if (!isset($this->started[$id]['out'])) {
59 $message .= sprintf('%s<bg=green;fg=white> %s </> ', $this->getBorder($id), $prefix);
60 $this->started[$id]['out'] = \true;
61 }
62 $message .= str_replace("\n", sprintf("\n%s<bg=green;fg=white> %s </> ", $this->getBorder($id), $prefix), $buffer);
63 }
64 return $message;
65 }
66 /**
67 * Stops a formatting session.
68 *
69 * @return string
70 */
71 public function stop(string $id, string $message, bool $successful, string $prefix = 'RES')
72 {
73 $trailingEOL = isset($this->started[$id]['out']) || isset($this->started[$id]['err']) ? "\n" : '';
74 if ($successful) {
75 return sprintf("%s%s<bg=green;fg=white> %s </> <fg=green>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
76 }
77 $message = sprintf("%s%s<bg=red;fg=white> %s </> <fg=red>%s</>\n", $trailingEOL, $this->getBorder($id), $prefix, $message);
78 unset($this->started[$id]['out'], $this->started[$id]['err']);
79 return $message;
80 }
81 private function getBorder(string $id) : string
82 {
83 return sprintf('<bg=%s> </>', self::COLORS[$this->started[$id]['border']]);
84 }
85 /**
86 * {@inheritdoc}
87 */
88 public function getName()
89 {
90 return 'debug_formatter';
91 }
92 }
93