* Helper: basename of a folder key. "root" -> "root", "foo/bar" -> "bar". */
(?string $key)
| 958 | * Helper: basename of a folder key. "root" -> "root", "foo/bar" -> "bar". |
| 959 | */ |
| 960 | private static function basenameKey(?string $key): string |
| 961 | { |
| 962 | if ($key === null || $key === '' || $key === 'root') { |
| 963 | return 'root'; |
| 964 | } |
| 965 | $key = trim($key, '/'); |
| 966 | $pos = strrpos($key, '/'); |
| 967 | if ($pos === false) { |
| 968 | return $key; |
| 969 | } |
| 970 | return substr($key, $pos + 1); |
| 971 | } |
| 972 | |
| 973 | /** |
| 974 | * Helper: approximate depth of a folder key (root->0, "foo"->1, "foo/bar"->2, etc.) |