MCPcopy Create free account
hub / github.com/error311/FileRise / parentKeyOf

Method parentKeyOf

src/FileRise/Domain/DiskUsageModel.php:940–955  ·  view source on GitHub ↗

* Helper: derive the parent folder key ("root" -> null, "foo/bar" -> "foo"). */

(string $key)

Source from the content-addressed store, hash-verified

938 * Helper: derive the parent folder key ("root" -> null, "foo/bar" -> "foo").
939 */
940 private static function parentKeyOf(string $key): ?string
941 {
942 if ($key === 'root' || $key === '') {
943 return null;
944 }
945 $key = trim($key, '/');
946 if ($key === '') {
947 return null;
948 }
949 $pos = strrpos($key, '/');
950 if ($pos === false) {
951 return 'root';
952 }
953 $parent = substr($key, 0, $pos);
954 return ($parent === '' ? 'root' : $parent);
955 }
956
957 /**
958 * Helper: basename of a folder key. "root" -> "root", "foo/bar" -> "bar".

Callers 1

buildSnapshotMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected