ajout str::indent()

This commit is contained in:
Jephté Clain 2025-09-29 11:46:40 +04:00
parent 328169f6c5
commit 07b9324de8

View File

@ -392,6 +392,18 @@ class str {
return implode($glue, $pieces);
}
/**
* indenter chaque ligne de $text
*/
static function indent(?string $text, string $indent=" "): ?string {
if ($text === null) return null;
$indented = [];
foreach (explode("\n", $text) as $line) {
$indented[] = "$indent$line";
}
return implode("\n", $indented);
}
const CAMEL_PATTERN0 = '/([A-Z0-9]+)$/A';
const CAMEL_PATTERN1 = '/([A-Z0-9]+)[A-Z]/A';
const CAMEL_PATTERN2 = '/([A-Z]?[^A-Z]+)/A';