mirror of
https://github.com/DanielnetoDotCom/YouPHPTube
synced 2025-10-05 10:49:36 +02:00
Update composer
This commit is contained in:
parent
330cdbe615
commit
0c83c9a678
442 changed files with 9523 additions and 10793 deletions
100
vendor/symfony/console/Helper/Helper.php
vendored
100
vendor/symfony/console/Helper/Helper.php
vendored
|
@ -21,31 +21,45 @@ use Symfony\Component\String\UnicodeString;
|
|||
*/
|
||||
abstract class Helper implements HelperInterface
|
||||
{
|
||||
protected $helperSet;
|
||||
protected $helperSet = null;
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function setHelperSet(?HelperSet $helperSet = null)
|
||||
{
|
||||
if (1 > \func_num_args()) {
|
||||
trigger_deprecation('symfony/console', '6.2', 'Calling "%s()" without any arguments is deprecated, pass null explicitly instead.', __METHOD__);
|
||||
}
|
||||
$this->helperSet = $helperSet;
|
||||
}
|
||||
|
||||
public function getHelperSet(): ?HelperSet
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getHelperSet()
|
||||
{
|
||||
return $this->helperSet;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the length of a string, using mb_strwidth if it is available.
|
||||
*
|
||||
* @deprecated since Symfony 5.3
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public static function strlen(?string $string)
|
||||
{
|
||||
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__);
|
||||
|
||||
return self::width($string);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the width of a string, using mb_strwidth if it is available.
|
||||
* The width is how many characters positions the string will use.
|
||||
*/
|
||||
public static function width(?string $string): int
|
||||
{
|
||||
$string ??= '';
|
||||
$string ?? $string = '';
|
||||
|
||||
if (preg_match('//u', $string)) {
|
||||
return (new UnicodeString($string))->width(false);
|
||||
|
@ -64,7 +78,7 @@ abstract class Helper implements HelperInterface
|
|||
*/
|
||||
public static function length(?string $string): int
|
||||
{
|
||||
$string ??= '';
|
||||
$string ?? $string = '';
|
||||
|
||||
if (preg_match('//u', $string)) {
|
||||
return (new UnicodeString($string))->length();
|
||||
|
@ -79,10 +93,12 @@ abstract class Helper implements HelperInterface
|
|||
|
||||
/**
|
||||
* Returns the subset of a string, using mb_substr if it is available.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public static function substr(?string $string, int $from, ?int $length = null): string
|
||||
public static function substr(?string $string, int $from, ?int $length = null)
|
||||
{
|
||||
$string ??= '';
|
||||
$string ?? $string = '';
|
||||
|
||||
if (false === $encoding = mb_detect_encoding($string, null, true)) {
|
||||
return substr($string, $from, $length);
|
||||
|
@ -91,52 +107,35 @@ abstract class Helper implements HelperInterface
|
|||
return mb_substr($string, $from, $length, $encoding);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function formatTime(int|float $secs, int $precision = 1)
|
||||
public static function formatTime($secs)
|
||||
{
|
||||
$secs = (int) floor($secs);
|
||||
|
||||
if (0 === $secs) {
|
||||
return '< 1 sec';
|
||||
}
|
||||
|
||||
static $timeFormats = [
|
||||
[1, '1 sec', 'secs'],
|
||||
[60, '1 min', 'mins'],
|
||||
[3600, '1 hr', 'hrs'],
|
||||
[86400, '1 day', 'days'],
|
||||
[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],
|
||||
];
|
||||
|
||||
$times = [];
|
||||
foreach ($timeFormats as $index => $format) {
|
||||
$seconds = isset($timeFormats[$index + 1]) ? $secs % $timeFormats[$index + 1][0] : $secs;
|
||||
if ($secs >= $format[0]) {
|
||||
if ((isset($timeFormats[$index + 1]) && $secs < $timeFormats[$index + 1][0])
|
||||
|| $index == \count($timeFormats) - 1
|
||||
) {
|
||||
if (2 == \count($format)) {
|
||||
return $format[1];
|
||||
}
|
||||
|
||||
if (isset($times[$index - $precision])) {
|
||||
unset($times[$index - $precision]);
|
||||
return floor($secs / $format[2]).' '.$format[1];
|
||||
}
|
||||
}
|
||||
|
||||
if (0 === $seconds) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$unitCount = ($seconds / $format[0]);
|
||||
$times[$index] = 1 === $unitCount ? $format[1] : $unitCount.' '.$format[2];
|
||||
|
||||
if ($secs === $seconds) {
|
||||
break;
|
||||
}
|
||||
|
||||
$secs -= $seconds;
|
||||
}
|
||||
|
||||
return implode(', ', array_reverse($times));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public static function formatMemory(int $memory)
|
||||
{
|
||||
if ($memory >= 1024 * 1024 * 1024) {
|
||||
|
@ -155,8 +154,15 @@ abstract class Helper implements HelperInterface
|
|||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @deprecated since Symfony 5.3
|
||||
*/
|
||||
public static function strlenWithoutDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
trigger_deprecation('symfony/console', '5.3', 'Method "%s()" is deprecated and will be removed in Symfony 6.0. Use Helper::removeDecoration() instead.', __METHOD__);
|
||||
|
||||
return self::width(self::removeDecoration($formatter, $string));
|
||||
}
|
||||
|
||||
public static function removeDecoration(OutputFormatterInterface $formatter, ?string $string)
|
||||
{
|
||||
$isDecorated = $formatter->isDecorated();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue