mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-17 21:49:04 +01:00
Add Str::dotNotationToBrackets()
This commit is contained in:
parent
a81a076c8d
commit
cd03ccba05
@ -154,4 +154,13 @@ class Str
|
||||
{
|
||||
return static::endsWith($haystack, $needle) ? substr($haystack, 0, -strlen($needle)) : $haystack;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert dot notation to brackets notation
|
||||
*/
|
||||
public static function dotNotationToBrackets(string $string): string
|
||||
{
|
||||
$segments = explode('.', $string);
|
||||
return array_shift($segments) . implode('', Arr::map($segments, fn ($segment) => '[' . $segment . ']'));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user