public function clear() { if (null === $this->json) { $this->load(); } // Subtract root which is not deleted $removed = count($this->getReferencesForRegex('/', '~.~')) - 1; $this->json = array(); $this->flush(); return $removed; }