Validates the ID of an entity

@param int $id
@throws \InvalidArgumentException
184803
public function validateId($id)
    {
        if (null === $id) {
            throw new \InvalidArgumentException('Category id missing');
        } elseif (!is_numeric($id) || (int)$id != $id) {
            throw new \InvalidArgumentException('Invalid data type for category id');
        }
    }
1110357
public function isValidCurrencyId($id) {
        $this->sError = FALSE;

        if (!$this->getCurrencyId2Code($id)) {
            $this->sError = 'Incorect currency id: ' . $id;
            return FALSE;
        }

        return TRUE;
    }
94500
public static void validateId(final String id) {
    if (id == null || id.isEmpty()) {
      throw new IllegalArgumentException("The ID cannot be null or empty");
    }
    for (int i = 0; i < id.length(); i++) {
      final char c = id.charAt(i);
      if (!(Character.isLetterOrDigit(c))) {
        throw new IllegalArgumentException("Invalid id (\"" + id + 
            "\"): illegal character: " + c);
      }
    }
    if (id.length() == 1) {
      if (Character.isDigit(id.charAt(0))) {
        throw new IllegalArgumentException("The ID cannot be an integer");
      }
    }
  }
95551
public function index(string $id = null)
    {
        if (empty($id)) {
            throw new InvalidArgumentException();
        }

        $list = $this->DblistItems->Dblists->get($id);
        $query = $this->DblistItems->find('treeEntities', ['listId' => $id]);

        if ($query->isEmpty()) {
            $this->Flash->set('List is empty, do you want to add new item?');

            return $this->redirect(['action' => 'add', $id]);
        }

        $this->set(compact('query', 'list'));
        $this->set('_serialize', ['entities']);
    }
344910
public function setDatatableId($id)
    {
        if (!array_key_exists($id, self::$_instances))
        {
            self::$_instances[$id] = $this;
        }
        else
        {
            throw new \Exception('Identifer already exists');
        }
        return $this;
    }
965699
protected function assertValidId($id)
    {
        if (defined('PHP_WINDOWS_VERSION_BUILD')) {
            $bad = preg_match('/[\x00-\x1F\x7F]\<\>\:\"\|\?\*]/', $id);
        } else {
            $bad = preg_match('/\x00/', $id);
        }
        if ($bad) {
            throw new RawFileCacheException('Invalid character found in cache ID', RawFileCacheException::INVALID_CHARACTER);
        }
    }
1058385
public function getNode($id)
    {
        if (!isset($this->nodes[$id])) {
            throw new InvalidArgumentException(sprintf('There is no node with id "%s".', $id));
        }

        return $this->nodes[$id];
    }
885333
public function isValidId(?string $id): bool
    {
        if ($id == '') {
            return false;
        }

        if ($this->saveHandler != null && method_exists($this->saveHandler, 'isValidId')) {
            return $this->saveHandler->isValidId($id);
        }

        static $idPattern;
        if ($idPattern == null) {
            if ($this->options['hash']) {
                $idPattern = '~^[A-F0-9]{'. $this->options['hashLength'] .'}$~';
            } else {
                // @see http://php.net/manual/en/session.configuration.php#ini.session.sid-length
                // @see http://php.net/manual/en/session.configuration.php#ini.session.sid-bits-per-character
                // @see https://github.com/php/php-src/blob/PHP-7.1/UPGRADING#L114
                $idLength = ini_get('session.sid_length') ?: self::SID_LENGTH;
                $idBitsPerCharacter = ini_get('session.sid_bits_per_character');
                if ($idBitsPerCharacter == '') { // never happens, but obsession..
                    ini_set('session.sid_length', (string) self::SID_LENGTH);
                    ini_set('session.sid_bits_per_character', (string) ($idBitsPerCharacter = self::SID_BITSPERCHARACTER));
                }

                $idCharacters = '';
                switch ((int) $idBitsPerCharacter) {
                    case 4: $idCharacters = '0-9a-f'; break;
                    case 5: $idCharacters = '0-9a-v'; break;
                    case 6: $idCharacters = '0-9a-zA-Z-,'; break;
                }

                $idPattern = '~^['. $idCharacters .']{'. $idLength .'}$~';
            }
        }

        return (bool) preg_match($idPattern, $id);
    }
698917
public function setId( $id )
	{
		if( $id === $this->getId() ) { return; }

		$this->_values['id'] = (string) $id ;
		$this->setModified();
	}
236143
public function delete($id)
    {
        $response = false;
        if (empty($id)) {
            throw new \InvalidArgumentException('ID Product cannot be empty');
        }

        try {
            $apiResponse = $this->client->delete("{$this->uriImport}product/{$id}", [
                'query' => [
                    'key' => $this->config['data']['key'],
                ],
            ]);

            $apiResponse = json_decode($apiResponse->getBody(), true);

            if (isset($apiResponse['affected']) && $apiResponse['affected'] > 0) {
                $response = true;
            }
        } catch (ClientException $e) {
            $response = false;
        }

        return $response;
    }
646576
public function hasRule($id) {
        $id = $this->normalizeID($id);
        return !empty($this->rules[$id]);
    }
329616
private static void validateId(String id) {

        if (id == null) {
            return;
        }
        int n = id.length();
        if (n < 1) {
            throw new IllegalArgumentException("Empty id attribute is not allowed");
        }
        for (int i = 0; i < n; i++) {
            char c = id.charAt(i);
            if (i == 0) {
                if (!Character.isLetter(c) && (c != '_')) {
                    throw new IllegalArgumentException(id);
                }
            } else {
                if (!Character.isLetter(c) &&
                        !Character.isDigit(c) &&
                        (c != '-') && (c != '_')) {
                    throw new IllegalArgumentException(id);
                }
            }
        }

    }
512133
public function validateId($id)
    {
        $id_string = $id->toString();
        $this->context[] = "id '$id_string'";
        if (!$id instanceof HTMLPurifier_ConfigSchema_Interchange_Id) {
            // handled by InterchangeBuilder
            $this->error(false, 'is not an instance of HTMLPurifier_ConfigSchema_Interchange_Id');
        }
        // keys are now unconstrained (we might want to narrow down to A-Za-z0-9.)
        // we probably should check that it has at least one namespace
        $this->with($id, 'key')
            ->assertNotEmpty()
            ->assertIsString(); // implicit assertIsString handled by InterchangeBuilder
        array_pop($this->context);
    }
757895
public function setId($id)
    {
       	if ($id !== null && is_numeric($id)) {
            $id = (int) $id;
        }
        $this->id = $id;

        return $this;
    }
1356265
public function setTypeId( $id )
	{
		$id = (int) $id;
		if ( $id === $this->getTypeId() ) { return; }

		$this->_values['typeid'] = (int) $id;
		$this->setModified();
	}
650810
public function deleteById($id)
    {
        $this->validateTableAndIdentityColumn();
        // If the soft delete is activated
        if ($this->deleteColumnName) {
            $query = <<<EOQ
UPDATE {$this->getTableName()}
SET {$this->deleteColumnName} = 1
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s
EOQ;
        } else {
            $query = <<<EOQ
DELETE FROM {$this->getTableName()}
WHERE {$this->escapeCharacter}{$this->identityColumn}{$this->escapeCharacter} = %s
EOQ;
        }

        $params = array('identity' => $id);

        return (bool)$this->db->query($query, $params);
    }
99464
public function offsetGet($id)
    {
        if (!array_key_exists($id, $this->container)) {
            throw new InvalidArgumentException(sprintf('Identifier "%s" is not defined.', $id));
        }

        return $this->container[$id] instanceof Closure ? $this->container[$id]($this) : $this->container[$id];
    }