PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 1.30.0
Independent Analytics – WordPress Analytics Plugin v1.30.0
2.15.5 2.15.4 2.15.3 2.15.2 2.15.1 2.15.0 2.14.10 trunk 1.1 1.10 1.10.1 1.11 1.12 1.13 1.14 1.15 1.16 1.17 1.17.1 1.17.2 1.17.3 1.17.4 1.18 1.18.1 1.19.0 1.19.1 1.2 1.20.0 1.21.0 1.22.0 1.22.1 1.23.0 1.23.1 1.24.0 1.24.1 1.25.0 1.25.1 1.26.0 1.27.0 1.28.0 1.28.1 1.28.2 1.28.3 1.29.0 1.3 1.30.0 1.30.1 1.4 1.5 1.6 1.7 1.8 1.9 2.0.0 2.0.1 2.1.4 2.1.5 2.1.6 2.10.0 2.10.1 2.10.2 2.10.3 2.10.4 2.11.0 2.11.1 2.11.10 2.11.2 2.11.3 2.11.4 2.11.5 2.11.6 2.11.7 2.11.8 2.11.9 2.12.0 2.12.1 2.12.2 2.13.1 2.13.2 2.13.5 2.13.6 2.14.0 2.14.1 2.14.2 2.14.4 2.14.6 2.14.7 2.14.8 2.14.9 2.2.0 2.2.1 2.3.1 2.3.2 2.4.2 2.4.3 2.5.0 2.5.1 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 2.7.0 2.7.1 2.7.2 2.7.3 2.8.2 2.8.3 2.8.4 2.8.5 2.8.6 2.8.7 2.8.8 2.8.9 2.9.2 2.9.3 2.9.4 2.9.5 2.9.6 2.9.7
independent-analytics / vendor / symfony / console / Helper / Helper.php
independent-analytics / vendor / symfony / console / Helper Last commit date
DebugFormatterHelper.php 3 years ago DescriptorHelper.php 3 years ago Dumper.php 3 years ago FormatterHelper.php 3 years ago Helper.php 3 years ago HelperInterface.php 3 years ago HelperSet.php 3 years ago InputAwareHelper.php 3 years ago ProcessHelper.php 3 years ago ProgressBar.php 3 years ago ProgressIndicator.php 3 years ago QuestionHelper.php 3 years ago SymfonyQuestionHelper.php 3 years ago Table.php 3 years ago TableCell.php 3 years ago TableCellStyle.php 3 years ago TableRows.php 3 years ago TableSeparator.php 3 years ago TableStyle.php 3 years ago
Helper.php
141 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 IAWP_SCOPED\Symfony\Component\Console\Helper;
12
13 use IAWP_SCOPED\Symfony\Component\Console\Formatter\OutputFormatterInterface;
14 use IAWP_SCOPED\Symfony\Component\String\UnicodeString;
15 /**
16 * Helper is the base class for all helper classes.
17 *
18 * @author Fabien Potencier <fabien@symfony.com>
19 */
20 abstract class Helper implements HelperInterface
21 {
22 protected $helperSet = null;
23 /**
24 * {@inheritdoc}
25 */
26 public function setHelperSet(HelperSet $helperSet = null)
27 {
28 $this->helperSet = $helperSet;
29 }
30 /**
31 * {@inheritdoc}
32 */
33 public function getHelperSet()
34 {
35 return $this->helperSet;
36 }
37 /**
38 * Returns the length of a string, using mb_strwidth if it is available.
39 *
40 * @deprecated since Symfony 5.3
41 *
42 * @return int
43 */
44 public static function strlen(?string $string)
45 {
46 trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::width() or Helper::length() instead.', __METHOD__);
47 return self::width($string);
48 }
49 /**
50 * Returns the width of a string, using mb_strwidth if it is available.
51 * The width is how many characters positions the string will use.
52 */
53 public static function width(?string $string) : int
54 {
55 $string ?? ($string = '');
56 if (\preg_match('//u', $string)) {
57 return (new UnicodeString($string))->width(\false);
58 }
59 if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {
60 return \strlen($string);
61 }
62 return \mb_strwidth($string, $encoding);
63 }
64 /**
65 * Returns the length of a string, using mb_strlen if it is available.
66 * The length is related to how many bytes the string will use.
67 */
68 public static function length(?string $string) : int
69 {
70 $string ?? ($string = '');
71 if (\preg_match('//u', $string)) {
72 return (new UnicodeString($string))->length();
73 }
74 if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {
75 return \strlen($string);
76 }
77 return \mb_strlen($string, $encoding);
78 }
79 /**
80 * Returns the subset of a string, using mb_substr if it is available.
81 *
82 * @return string
83 */
84 public static function substr(?string $string, int $from, int $length = null)
85 {
86 $string ?? ($string = '');
87 if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {
88 return \substr($string, $from, $length);
89 }
90 return \mb_substr($string, $from, $length, $encoding);
91 }
92 public static function formatTime($secs)
93 {
94 static $timeFormats = [[0, '< 1 sec'], [1, '1 sec'], [2, 'secs', 1], [60, '1 min'], [120, 'mins', 60], [3600, '1 hr'], [7200, 'hrs', 3600], [86400, '1 day'], [172800, 'days', 86400]];
95 foreach ($timeFormats as $index => $format) {
96 if ($secs >= $format[0]) {
97 if (isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0] || $index == \count($timeFormats) - 1) {
98 if (2 == \count($format)) {
99 return $format[1];
100 }
101 return \floor($secs / $format[2]) . ' ' . $format[1];
102 }
103 }
104 }
105 }
106 public static function formatMemory(int $memory)
107 {
108 if ($memory >= 1024 * 1024 * 1024) {
109 return \sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
110 }
111 if ($memory >= 1024 * 1024) {
112 return \sprintf('%.1f MiB', $memory / 1024 / 1024);
113 }
114 if ($memory >= 1024) {
115 return \sprintf('%d KiB', $memory / 1024);
116 }
117 return \sprintf('%d B', $memory);
118 }
119 /**
120 * @deprecated since Symfony 5.3
121 */
122 public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
123 {
124 trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
125 return self::width(self::removeDecoration($formatter, $string));
126 }
127 public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
128 {
129 $isDecorated = $formatter->isDecorated();
130 $formatter->setDecorated(\false);
131 // remove <...> formatting
132 $string = $formatter->format($string ?? '');
133 // remove already formatted characters
134 $string = \preg_replace("/\x1b\\[[^m]*m/", '', $string ?? '');
135 // remove terminal hyperlinks
136 $string = \preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
137 $formatter->setDecorated($isDecorated);
138 return $string;
139 }
140 }
141