{@inheritDoc}

If the key cannot be found in the collection, an exception is thrown.

@throws CollectionIDNotFoundException
@return void
357571
public function deleteID($ID)
    {
        if($this->offsetExists($this->safeOffset($ID))) {
            $this->offsetUnset($this->safeOffset($ID));
        } else {
            throw new CollectionIDNotFoundException('ID "' . $ID . '" does not exist in collection');
        }
    }
225966
public function lset($collection, $key, $index, $value) {

        $list = $this->getKey($collection, $key, []);

        if ($index < 0) {
            $index = count($list) - abs($index);
        }

        if (isset($list[$index])){
            $list[$index] = $value;
            $this->setKey($collection, $key, $list);

            return true;
        }

        return false;
    }
1105552
public function findOrFail($name)
    {
        $result = $this->find($name);

        if (is_null($result)) {
            throw new CollectionItemNotFoundException(sprintf('Collection item "%s" not found', $name));
        }

        return $result;
    }
1230432
public function get($key)
	{
		if (isset($this->items[$key])) {
			return $this->items[$key];
		} else {
			throw new InvalidKeyException("Collection key '" . $key . "' does not exist.");
		}
	}
639074
public function hasKey($key, $collection)
    {
        if (empty($this->queriesResultCache[ 'collectionKeys' ][ $collection ])) {
            $this->getKeys($collection);
        }

        return (bool)in_array($key, $this->queriesResultCache[ 'collectionKeys' ][ $collection ]);
    }
1024176
protected function initializeCollections()
    {
        foreach ($this->settings['collections'] as $collectionName => $collectionDefinition) {
            if (!isset($collectionDefinition['storage'])) {
                throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has no valid "storage" option. Please check the configuration syntax.', $collectionName), 1361468805);
            }
            if (!isset($this->storages[$collectionDefinition['storage']])) {
                throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings referred to a non-existing storage "%s". Please check the configuration syntax and make sure to specify a valid storage class name.', $collectionName, $collectionDefinition['storage']), 1361481031);
            }
            if (!isset($collectionDefinition['target'])) {
                throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has no valid "target" option. Please check the configuration syntax and make sure to specify a valid target class name.', $collectionName), 1361468923);
            }
            if (!isset($this->targets[$collectionDefinition['target']])) {
                throw new Exception(sprintf('The configuration for the resource collection "%s" defined in your settings has not defined a valid "target" option. Please check the configuration syntax and make sure that the specified class "%s" really exists.', $collectionName, $collectionDefinition['target']), 1361468924);
            }

            $pathPatterns = (isset($collectionDefinition['pathPatterns'])) ? $collectionDefinition['pathPatterns'] : [];
            $filenames = (isset($collectionDefinition['filenames'])) ? $collectionDefinition['filenames'] : [];

            $this->collections[$collectionName] = new Collection($collectionName, $this->storages[$collectionDefinition['storage']], $this->targets[$collectionDefinition['target']], $pathPatterns, $filenames);
        }
    }
385768
public function __isset($key)
    {
        if (!is_string($key) && !is_integer($key)) {
            throw new \Exception('Error the key (' . gettype($key) . ') is not a string or an integer : ' . json_encode($key));
        }

        return array_key_exists($key, $this->collection);
    }
392449
public function setKey($collection, $key, $value) {

        $entry = $this->driver->findOne($collection, ['key' => $key]);

        if ($entry) {
            $entry['val'] = $value;
        } else {
            $entry = [
                'key' => $key,
                'val' => $value
            ];
        }

        return $this->driver->save($collection, $entry);
    }
1153895
private function validateKey(string $key): void
    {
        $key_pattern = $this->cache->getOptions()->getKeyPattern();

        if ($key === '') {
            throw new InvalidKeyException('An empty key is not allowed');
        } elseif (!empty($key_pattern && !preg_match($key_pattern, $key))) {
            throw new InvalidKeyException(
                sprintf('The key "%s" does not match against pattern "%s"', $key, $key_pattern)
            );
        }
    }
1119817
public function deleteRow($id)
    {
        if ($id === self::ID_SUMMARY_ROW) {
            $this->summaryRow = null;
            return;
        }
        if (!isset($this->rows[$id])) {
            throw new Exception("Trying to delete unknown row with idkey = $id");
        }
        unset($this->rows[$id]);
    }
1042143
public function incrKey($collection, $key, $by = 1) {

        $current = $this->getKey($collection, $key, 0);
        $newone  = $current + $by;

        $this->setKey($collection, $key, $newone);

        return $newone;
    }
53317
protected function collection_query( &$collection ) 
	{
		$local_keys = array();
		
		foreach( $collection as $item )
		{
			$local_keys[] = $item->raw( $this->local_key );
		}
		
		// set the correct collection where
		$this->query->wheres = array();
		$this->query->where( $this->foreign_key, 'in', $local_keys );
		$this->query->group_result( $this->foreign_key );
		
		$this->query->limit( null );
	}
1080609
public function parameters($key, $ruleName)
    {
        if (!isset($this->failures[$key])) {
            throw new KeyNotFoundException("Key '$key' has no failures");
        }

        if (!isset($this->failures[$key][$ruleName])) {
            throw new KeyNotFoundException("Key '$key' has no failed rule '$ruleName'");
        }

        return $this->failures[$key][$ruleName];
    }
1101634
public function find($storageName, $key)
    {
        $qb = $this->conn->createQueryBuilder();

        $qb->select('s.' . $this->dataColumn)
            ->from($this->table, 's')
            ->where($this->keyColumn . ' = ?')
            ->setParameters([$key]);

        $stmt = $qb->execute();

        $data = $stmt->fetchColumn();

        if (! $data) {
            throw new NotFoundException();
        }

        return unserialize($data);
    }
136691
public function setInternalKey($key)
    {
        if ($this->_key !== null && $this->_key !== $key) {
            throw new ClientException('Should not update the key of an existing document');
        }

        if (!preg_match('/^[a-zA-Z0-9_:.@\-()+,=;$!*\'%]{1,254}$/', $key)) {
            throw new ClientException('Invalid format for document key');
        }

        $this->_key = (string) $key;
    }
471374
public function delete($key)
	{
	    $this->validateKey($key);

		if (isset($this->items[$key])) {
			unset($this->items[$key]);
		} else {
			throw new InvalidKeyException("Collection key '".$key."' does not exist.");
		}
	}
145128
public function remove($id) {
		// Format id
		$id = $this->_format($id);
		// Verify existence
		if(!$this->has($id)) {
			throw new NotFoundException("'$id' value does not exist");
		}
		// Remove value
		unset($this->values[$id]);
	}