PluginProbe ʕ •ᴥ•ʔ
Independent Analytics – WordPress Analytics Plugin / 2.2.0
Independent Analytics – WordPress Analytics Plugin v2.2.0
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 2 years ago DescriptorHelper.php 2 years ago Dumper.php 2 years ago FormatterHelper.php 2 years ago Helper.php 2 years ago HelperInterface.php 2 years ago HelperSet.php 2 years ago InputAwareHelper.php 2 years ago ProcessHelper.php 2 years ago ProgressBar.php 2 years ago ProgressIndicator.php 2 years ago QuestionHelper.php 2 years ago SymfonyQuestionHelper.php 2 years ago Table.php 2 years ago TableCell.php 2 years ago TableCellStyle.php 2 years ago TableRows.php 3 years ago TableSeparator.php 2 years ago TableStyle.php 2 years ago
Helper.php
142 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 * @internal
20 */
21 abstract class Helper implements HelperInterface
22 {
23 protected $helperSet = null;
24 /**
25 * {@inheritdoc}
26 */
27 public function setHelperSet(HelperSet $helperSet = null)
28 {
29 $this->helperSet = $helperSet;
30 }
31 /**
32 * {@inheritdoc}
33 */
34 public function getHelperSet()
35 {
36 return $this->helperSet;
37 }
38 /**
39 * Returns the length of a string, using mb_strwidth if it is available.
40 *
41 * @deprecated since Symfony 5.3
42 *
43 * @return int
44 */
45 public static function strlen(?string $string)
46 {
47 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__);
48 return self::width($string);
49 }
50 /**
51 * Returns the width of a string, using mb_strwidth if it is available.
52 * The width is how many characters positions the string will use.
53 */
54 public static function width(?string $string) : int
55 {
56 $string ?? ($string = '');
57 if (\preg_match('//u', $string)) {
58 return (new UnicodeString($string))->width(\false);
59 }
60 if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {
61 return \strlen($string);
62 }
63 return \mb_strwidth($string, $encoding);
64 }
65 /**
66 * Returns the length of a string, using mb_strlen if it is available.
67 * The length is related to how many bytes the string will use.
68 */
69 public static function length(?string $string) : int
70 {
71 $string ?? ($string = '');
72 if (\preg_match('//u', $string)) {
73 return (new UnicodeString($string))->length();
74 }
75 if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {
76 return \strlen($string);
77 }
78 return \mb_strlen($string, $encoding);
79 }
80 /**
81 * Returns the subset of a string, using mb_substr if it is available.
82 *
83 * @return string
84 */
85 public static function substr(?string $string, int $from, int $length = null)
86 {
87 $string ?? ($string = '');
88 if (\false === ($encoding = \mb_detect_encoding($string, null, \true))) {
89 return \substr($string, $from, $length);
90 }
91 return \mb_substr($string, $from, $length, $encoding);
92 }
93 public static function formatTime($secs)
94 {
95 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]];
96 foreach ($timeFormats as $index => $format) {
97 if ($secs >= $format[0]) {
98 if (isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0] || $index == \count($timeFormats) - 1) {
99 if (2 == \count($format)) {
100 return $format[1];
101 }
102 return \floor($secs / $format[2]) . ' ' . $format[1];
103 }
104 }
105 }
106 }
107 public static function formatMemory(int $memory)
108 {
109 if ($memory >= 1024 * 1024 * 1024) {
110 return \sprintf('%.1f GiB', $memory / 1024 / 1024 / 1024);
111 }
112 if ($memory >= 1024 * 1024) {
113 return \sprintf('%.1f MiB', $memory / 1024 / 1024);
114 }
115 if ($memory >= 1024) {
116 return \sprintf('%d KiB', $memory / 1024);
117 }
118 return \sprintf('%d B', $memory);
119 }
120 /**
121 * @deprecated since Symfony 5.3
122 */
123 public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
124 {
125 trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
126 return self::width(self::removeDecoration($formatter, $string));
127 }
128 public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
129 {
130 $isDecorated = $formatter->isDecorated();
131 $formatter->setDecorated(\false);
132 // remove <...> formatting
133 $string = $formatter->format($string ?? '');
134 // remove already formatted characters
135 $string = \preg_replace("/\x1b\\[[^m]*m/", '', $string ?? '');
136 // remove terminal hyperlinks
137 $string = \preg_replace('/\\033]8;[^;]*;[^\\033]*\\033\\\\/', '', $string ?? '');
138 $formatter->setDecorated($isDecorated);
139 return $string;
140 }
141 }
142