Return the nth occurrence of a subfield with specified code.

@param  string $code Subfield code
@param  integer $n Zero-based subfield index
@return \HAB\Pica\record\Subfield|null The requested subfield or NULL if
none exists
438789
public function getNthSubfield ($code, $n) 
    {
        $count = 0;
        foreach ($this->getSubfields() as $subfield) {
            if ($subfield->getCode() == $code) {
                if ($count == $n) {
                    return $subfield;
                }
                $count++;
            }
        }
        return null;
    }
677856
public function renderLine($code = null, $newLine = true)
    {
        if ($newLine && !empty($code) && $this->debug) {
            $code .= "\n";
        }

        return (string) $code;
    }
929723
public function getIdByCode(string $code): int
    {
        // pokud existuje kod v
        if (isset($this->locales[$code]['id'])) {
            return $this->locales[$code]['id'];
        }
        // pokud existuje kod v aliasu
        if (isset($this->aliasLocale[$code])) {
            $this->locales[$this->aliasLocale[$code]]['id'];
        }
        // jinak pouzije defaultni jazyk
        return ($this->locales[$this->defaultLocale]['id'] ?? 0);
    }
892602
public function getNextExpected($expectedCode)
    {
        $token = $this->getNext();
        if ($this->getCurrentCode() != $expectedCode) {
            return null;
        }

        return $token;
    }
1011777
protected function getNewFileVersions($code, $version = null)
    {
        if ($version === null) {
            $version = self::NO_VERSION_VALUE;
        }

        $versions = $this->getFileVersions($code);
        $position = array_search($version, array_keys($versions));
        return array_slice($versions, ++$position);
    }
54511
public static function getHierarchyChildren($code)
    {
        $length = static::getHierarchyChildLength($code);
        if ($length < -1) {
            throw new HierarchyException('xxxx');
        }

        $hierarchyField = static::getHierarchyField();
        return static::query()->whereStartsWith($hierarchyField, $code, $length)->values($hierarchyField);
    }
556703
public static function getReason($code, $default = NULL)
	{
		$code = (int)$code;
		
		if(array_key_exists($code, static::$reason))
		{
			return static::$reason[$code];
		}
		
		return $default;
	}
252443
public function findByActivationCode($code)
	{
		if ( ! $code)
		{
			throw new \InvalidArgumentException("No activation code passed.");
		}

		$model = $this->createModel();

		$result = $model->where('activation_code', '=', $code)->get();

		if (($count = $result->count()) > 1)
		{
			throw new \RuntimeException("Found [$count] users with the same activation code.");
		}

		 $user = $result->find();

		if ( !$user->loaded() )
		{
			throw new UserNotFoundException("A user was not found with the given activation code.");
		}

		return $user;
	}
1162996
protected function filtreCode($code)
    {
        if (is_numeric($code)) {
            $code = (int) $code;
        }
        if (!isset($this->reasonPhraseDefault[ $code ])) {
            throw new \InvalidArgumentException('Status code is invalid.');
        }

        return $code;
    }
1188498
final public function get($code = null) {

        if ( is_null($code) ) return $this->rpc_errors;

        else if ( array_key_exists($code, $this->rpc_errors) ) return $this->rpc_errors[$code];

        else if ( $code >= -32099 && $code <= -32000 ) return 'Server Error';

        else return 'Unknown Error';

    }
778209
protected function getPregErrorText($code = null)
    {
        $code = $code ?: preg_last_error();

        if (!isset(self::$pregErrors[$code])) {
            $code = PREG_NO_ERROR;
        }

        return self::$pregErrors[$code];
    }
978018
public function getReceptionCode($code)
    {
        static $codes = array();

        if (! isset($codes[$code])) {
            $codes[$code] = $this->_loadClass('receptionCode', true, array($code));
        }

        return $codes[$code];
    }
1114030
public static function getErrText($code)
    {
        if (isset(self::$errCode[$code])) {
            return self::$errCode[$code];
        }
        return false;
    }
147219
public static function getLogStringByCode($code)
    {
        $code = is_numeric($code) && !is_float($code)
            ? abs($code)
            : $code;
        if (!is_int($code)) {
            return null;
        }

        switch (self::getConvertAliasLogLevel($code)) {
            case Logger::NOTICE:
                return 'notice';
            case Logger::ERROR:
                return 'error';
            case Logger::WARNING:
                return 'warning';
            case Logger::INFO:
                return 'info';
            case Logger::DEBUG:
                return 'debug';
            case Logger::EMERGENCY:
                return 'emergency';
            case Logger::CRITICAL:
                return 'critical';
            case Logger::ALERT:
                return 'alert';
        }

        return null;
    }
1059982
protected function _getNextCode()
    {
        if ($this->_bytePointer == $this->_dataLength) {
            return 257;
        }

        $this->_nextData = ($this->_nextData << 8) | (ord($this->_data[$this->_bytePointer++]) & 0xff);
        $this->_nextBits += 8;

        if ($this->_nextBits < $this->_bitsToGet) {
            $this->_nextData = ($this->_nextData << 8) | (ord($this->_data[$this->_bytePointer++]) & 0xff);
            $this->_nextBits += 8;
        }

        $code = ($this->_nextData >> ($this->_nextBits - $this->_bitsToGet)) & $this->_andTable[$this->_bitsToGet-9];
        $this->_nextBits -= $this->_bitsToGet;

        return $code;
    }
672868
public static function getHierarchyChildLength($code)
    {
        $lengths = static::getHierarchyLengths();
        if ($code === '') {
            return $lengths[0];
        }

        $current_length = 0;
        $code_length = strlen($code);
        foreach ($lengths as $i => $length) {
            $current_length += $length;
            if ($current_length === $code_length) {
                if ($i >= count($lengths) - 1) {
                    return -1;
                } else {
                    return $current_length + $lengths[$i + 1];
                }
            }
        }

        return -1;
    }
899009
public function getHeader($code)
    {
        if (isset($this->headers[$code])) {
            return $this->headers[$code];
        }

        return null;
    }