public function offsetUnset($key)
    {
        $entityClass = $this->entityClass;

        if ($key instanceof $entityClass) {
            $this->entities = array_filter($this->entities, function ($v) use ($key) {
                return $v !== $key;
            });
            return true;
        }

        if (isset($this->entities[$key])) {
            unset($this->entities[$key]);
            return true;
        }

        return false;
    }