Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Return a formatted string
<?php sprintf(string $format, mixed ...$values): string
<?php $setCodes = implode(';', collection($this->parseColor($color))->toArray());
$unsetCodes = implode(';', collection(['39'])->toArray());
return sprintf(terminal()->getCsi() . '%sm', $setCodes) . $value . sprintf(terminal()->getCsi() . '%sm', $unsetCodes);
}
<?php $setCodes = implode(';', collection($this->parseColor($color, true))->toArray());
$unsetCodes = implode(';', collection(['49'])->toArray());
return sprintf(terminal()->getCsi() . '%sm', $setCodes) . $value . sprintf(terminal()->getCsi() . '%sm', $unsetCodes);
}
<?php public function getRandomHexColor(): string
{
return sprintf('#%06X', mt_rand(0, 0xFFFFFF));
}
<?php public function convertRgbColorToHex(string $color): string
{
if (preg_match('/(\d{1,3})\,?\s?(\d{1,3})\,?\s?(\d{1,3})/', $color, $matches)) {
$color = sprintf('%02x%02x%02x', $matches[1], $matches[2], $matches[3]);
}
return $color;
<?php }
if (strings($color)->length() !== 6) {
throw new InvalidArgumentException(sprintf('Invalid "%s" color.', $color));
}
return ($background ? '4' : '3') . $this->convertHexColorToAnsi(hexdec($color));
<?php return ($background ? '10' : '9') . self::BRIGHT_COLORS[$color];
}
throw new InvalidArgumentException(sprintf('Invalid "%s" color; expected one of (%s).', $color, implode(', ', array_merge(array_keys(self::COLORS), array_keys(self::BRIGHT_COLORS)))));
}
<?php return (string) $this->degradeHexColorToAnsi($r, $g, $b);
}
return sprintf('8;2;%d;%d;%d', $r, $g, $b);
}
<?php $code = trim(fread($input, 1024));
shell_exec(sprintf('stty %s', $sttyMode));
sscanf($code, terminal()->getCsi() . '%d;%dR', $row, $col);
<?php return $this->h(strings($method)->substr(1)->toInteger());
}
throw new BadMethodCallException(sprintf(
'Method %s::%s does not exist.',
static::class,
$method
));
}