Normalize a unit type ID. Turns some groups of unit IDs (such as gates in
four directions) into a single unit ID, so it's easier to work with.

@param int  $id  Unit type ID.
@return int Normalized unit type ID.
544808
public function normalizeUnit($id)
    {
        if ($this->isGateUnit($id)) {
            return Unit::GATE;
        }
        if ($this->isPalisadeGateUnit($id)) {
            return Unit::PALISADE_GATE;
        }
        return $id;
    }
427265
public function getLanguageID($id)
	{
		// normalize id
		$id = $this->getCanonicalID($id);
		// remove sub tags
		if(($underscorePosition=strpos($id, '_'))!== false)
		{
			$id = substr($id, 0, $underscorePosition);
		}
		return $id;
	}
448300
public function setID($id)
    {
        $dao = $this->getDAO();
        $pkey = $dao->getPrimaryKey();

        if (count($pkey) === 1 && is_scalar($id))
        {
            $pcol = reset($pkey);
            $this->setField($pcol->getName(), $id);
        }
        elseif (is_array($id) && array_keys($id) === array_keys($pkey))
        {
            foreach ($pkey as $name => $def)
            {
                $this->setField($name, $id[$name]);
            }
            $this->_id = $id;
        }
        else
        {
            throw new InvalidTypeException("Provided ID does not match primary key");
        }
        return $this;
    }
1261331
public function isGaiaObject($id)
    {
        return $id >= Unit::CLIFF1 && $id <= Unit::CLIFF10
            || $id === Unit::GOLDMINE
            || $id === Unit::STONEMINE
            || $id === Unit::FORAGEBUSH;
    }
773718
public function id($id = null)
    {
        if (is_null($id)) {
            return $this->id;
        }

        $this->id = $id;

        return $this;
    }
349048
public function get_page_type_idstring($id) {
        foreach ($this->types as $pagetype) {
            if ((int)$pagetype->typeid === (int)$id) {
                return $pagetype->idstring;
            }
        }
        return 'unknown';
    }
471455
protected function prepareId($id) {
		if (! is_scalar($id)) {
			$id = json_encode($id);
			
			if (isset($id[33])) {
				$id = md5($id);
			}
		}
		
		if ($this->namespace === null) {
			return $id;
		}
		
		return $this->namespace . '_' . $id;
	}
1356265
public function setTypeId( $id )
	{
		$id = (int) $id;
		if ( $id === $this->getTypeId() ) { return; }

		$this->_values['typeid'] = (int) $id;
		$this->setModified();
	}
285447
public static function findOrCreate($id)
    {
        if ($data = static::find($id)) {
            return $data;
        }

        $id = static::getMapper()->normalizeID($id);

        return new static($id);
    }
1322430
public static function id($id, $options = []) {
		if (is_array($id)) {
			$result = [];
			foreach ($id as $v) {
				$result[] = self::numberToFromNativeLanguage($v . '', $options);
			}
			return implode(self::$symbol_comma . ' ', $result);
		} else {
			return self::numberToFromNativeLanguage($id . '', $options);
		}
	}
234162
public function delete_bit(string $id): ?int
  {
    if ( \bbn\str::is_uid($id) ){
      return $this->db->delete($this->class_cfg['tables']['user_options_bits'], [
        $this->class_cfg['arch']['user_options_bits']['id'] => $id
      ]);
    }
    return null;
  }
420793
public function getDatabaseIdentifierValue($id)
    {
        $idType = $this->fieldMappings[$this->identifier]['type'];
        return Type::getType($idType)->convertToDatabaseValue($id);
    }
75258
public function getFromGroupWithChartType($id)
    {
        $query = $this->createQueryBuilder('c')
            ->join('c.libs', 'lib')
            ->addSelect('lib')
            ->join('lib.type', 'type')
            ->addSelect('type')
            ->where('c.idGroup = :idGroup')
            ->setParameter('idGroup', $id);

        return $query->getQuery()->getResult();
    }
890512
public function getIds($key)
    {
        $key = $key instanceof UnitOfTimeInterface ? $this->prefixKey . $key->getKey() : $this->prefixTempKey . $key;

        $string = $this->getRedisClient()->get($key);

        $data = $this->bitsetToString($string);

        $ids = array();
        while (false !== ($pos = strpos($data, '1'))) {
            $data[$pos] = 0;
            $ids[]  = (int)($pos/8)*8 + abs(7-($pos%8));
        }

        sort($ids);

        return $ids;
    }
559691
protected function createId($id)
    {
        if (is_null($id)) {
            return md5(join('_', [
                $this->config['shortcode'],
                $this->mobile,
                time(),
            ]));
        }

        return $id;
    }
672342
public function removeDefinition($id)
    {
        if (isset($this->definitions[$id = $this->normalizeId($id)])) {
            unset($this->definitions[$id]);
            $this->removedIds[$id] = true;
        }
    }
960746
private function getSharedItemKey(int $id): int
    {
        if ($id <= 0) {
            throw new \InvalidArgumentException('ID cannot be less or equals zero');
        }

        $st = @stat(__FILE__);
        if (!$st) {
            return -1;
        }

        //@TODO collisions? need more unique key
        $key = (int)sprintf("%u",
            (
                ($st['ino'] & 0xffff) |
                (($st['dev'] & 0xff) << 16) |
                (($id & 0xff) << 24)
            )
        );

        return $key;
    }