diff --git a/src/SeriousJSON/JsonDatabase.php b/src/SeriousJSON/JsonDatabase.php index 64a9bf1..b9dd89f 100644 --- a/src/SeriousJSON/JsonDatabase.php +++ b/src/SeriousJSON/JsonDatabase.php @@ -88,6 +88,32 @@ class JsonDatabase implements IJsonUnflattener return $retPath; } + public function exists(string $class, string $name, ?int $timestamp = null): bool + { + if ($class == null || empty(trim($name))) + return false; + + if ($name != null && !empty(trim(strval($name)))) + $name = JSONDatabase::SanitizeIdentifier($name); + else + return false; + + $class = trim($class); + + if (!$this->audit && $timestamp != null) + return false; + + $objPath = $this->getObjectPath($class, $name, ($timestamp != null)); + + if (strlen($objPath) > PHP_MAXPATHLEN) + return false; + + if (!is_file($objPath)) + return false; + + return true; + } + public function load(string $class, string $name, ?int $timestamp = null): JsonSerializable|null { if ($class == null || empty(trim($name))) diff --git a/src/SeriousJSON/JsonHistoryItem.php b/src/SeriousJSON/JsonHistoryItem.php deleted file mode 100644 index 70c0ac5..0000000 --- a/src/SeriousJSON/JsonHistoryItem.php +++ /dev/null @@ -1,7 +0,0 @@ -