Calcula e retorna o dígito verificador usando o algoritmo Modulo 11

@param string $num
@param int $base
@return array Retorna um array com as chaves 'digito' e 'resto'
353764
protected static function mod11($num)
    {
        $codigo_beneficiario = RemessaAbstract::$entryData['codigo_beneficiario'].RemessaAbstract::$entryData['codigo_beneficiario_dv']; // NÃºmero do contrato: Ã o mesmo nÃºmero da conta
        $agencia = RemessaAbstract::$entryData['agencia']; // NÃºmero do contrato: Ã o mesmo nÃºmero da conta

        $NossoNumero = str_pad($num,7,0,STR_PAD_LEFT); // Até 7 dígitos, nÃºmero sequencial iniciado em 1 (Ex.: 1, 2...)
        $qtde_nosso_numero = strlen($NossoNumero);
        $sequencia = str_pad($agencia,4,STR_PAD_LEFT).str_pad($codigo_beneficiario,10,0,STR_PAD_LEFT).str_pad($NossoNumero,7,0,STR_PAD_LEFT);
        $cont=0;
        $calculoDv = 0;
        for($num=0;$num<21;$num++) {
            $cont++;
            if($cont == 1)
            {
                $constante = 3;
            }
            if($cont == 2)
            {
                $constante = 1;
            }
            if($cont == 3)
            {
                $constante = 9;
            }
            if($cont == 4)
            {
                $constante = 7;
                $cont = 0;
            }
            $calculoDv = $calculoDv + (substr($sequencia,$num,1) * $constante);
        }

        $Resto = $calculoDv % 11;
        if($Resto == 0 || $Resto == 1){
            $Dv = 0;
        }else{
            $Dv = 11 - $Resto;
        }

        $result["nosso_numero"] = $NossoNumero;
        $result["digito"] = $Dv;
        return $result;
    }
1252363
public function setNum($num = 20)
    {
        if (!is_numeric($num) && $num !== self::SEARCH_ALL) {
            throw new \InvalidArgumentException(
                'Argument can only be numeric or "all" to return all results.'
            );
        }
        $this->otherOptions['num'] = $num;

        return $this;
    }
1096820
public function TryParseDouble( &$num )
	{
		if ( ! is_null( $this->_doubleValue ) )
		{
			$num = (double)$this->_doubleValue;
			return true;
		}
		if ( $this->CanBeNumber() )
		{
			if ( is_nan( $this->Value ) || $this->Value == "NAN" )
			{
				$num = NAN;
				$this->_doubleValue = $num;
				return true;
			}
			else if ( $this->Value == INF || $this->Value == "INF" )
			{
				$num = INF;
				$this->_doubleValue = $num;
				return true;
			}
			else if ( $this->Value == -INF || $this->Value == "-INF" )
			{
				$num = -INF;
				$this->_doubleValue = $num;
				return true;
			}
			else
			{
				$locale = \Collator::create( null )->getLocale( \Locale::VALID_LOCALE );
				$fmt = new \NumberFormatter( $locale, \NumberFormatter::DECIMAL );
				$num = $fmt->parse( $this->Value );
				if ( $num )
				{
					if ( $num == 0 ) $num = 0.0;
					$this->_doubleValue = $num;
					return true;
				}
			}
		}

		$num = 0.0;
		$this->_doubleValue = $num;
		return false;
	}
423518
public function mod(BN $num) {
        if (assert_options(ASSERT_ACTIVE)) assert(!$num->isZero());
        $res = clone($this);
        $res->bi = $res->bi->divR($num->bi);
        return $res;
    }
1022128
protected function gerarNossoNumero()
    {
        $convenio = $this->getConvenio();
        $numero_boleto = $this->getNumero();
        switch (strlen($convenio)) {
        case 4:
            $numero = Util::numberFormatGeral($convenio, 4) . Util::numberFormatGeral($numero_boleto, 7);
            break;
        case 6:
            if (in_array($this->getCarteira(), ['16', '18']) && $this->getVariacaoCarteira() == 17) {
                $numero = Util::numberFormatGeral($numero_boleto, 17);
            } else {
                $numero = Util::numberFormatGeral($convenio, 6) . Util::numberFormatGeral($numero_boleto, 5);
            }
            break;
        case 7:
            $numero = Util::numberFormatGeral($convenio, 7) . Util::numberFormatGeral($numero_boleto, 10);
            break;
        default:
            throw new \Exception('O código do convênio precisa ter 4, 6 ou 7 dígitos!');
        }
        return $numero;
    }
750897
public static function toRoman($num)
  {
    $num = (int)$num;
    switch($num){
      case 1:
        $roman = 'I';
        break;
      case 2:
        $roman = 'II';
        break;
      case 3:
        $roman = 'III';
        break;
      case 4:
        $roman = 'IV';
        break;
      case 5:
        $roman = 'V';
        break;
      case 6:
        $roman = 'VI';
        break;
      case 7:
        $roman = 'VII';
        break;
      case 8:
        $roman = 'VIII';
        break;
      case 9:
        $roman = 'IX';
        break;
      case 10:
        $roman = 'X';
        break;
      default:
        $roman = (string)$num;
        break;
    }
    
    return $roman;
  }
846072
private function imbReverseUs($num)
	{
		$rev = 0;
		for ($i = 0; $i < 16; ++$i) {
			$rev <<= 1;
			$rev |= ($num & 1);
			$num >>= 1;
		}
		return $rev;
	}
69808
public function numeric(int $base = 10): string
    {
        if ($base < 2 || $base > 36) {
            throw new \InvalidArgumentException('Base must be between 2 and 36 (included)');
        }

        $value = gmp_strval($this->ip, $base);

        // fix for newer versions of GMP (> 5.0) in PHP 5.4+ that removes
        // the leading 0 in base 2
        if ($base == 2) {
            $value = str_pad($value, static::NB_BITS, '0', STR_PAD_LEFT);
        }

        return $value;
    }
467187
public static function forSum(callable $num): self {
        return new self(
                function() { return 0; },
                function(&$result, $element) use($num) { $result+= $num($element); }
        );
    }
255481
protected function toWords($num)
    {
        $ret = '';
        $num = strval($num);

        if ((int)$num === 0) {
            return self::$digits[0];
        }

        if (substr($num, 0, 1) == '-') {
            $ret = $this->minus . $this->wordSeparator;
            $num = substr($num, 1);
        }

        $num = preg_replace('/^0+/', '', $num);
        $num_length = strlen($num);

        if ($num_length % 3 !== 0) {
            $num = str_pad($num, $num_length + (3-($num_length%3)), '0', STR_PAD_LEFT);
        }

        $groups = str_split($num, 3);
        $g_index = count($groups) - 1;
        foreach ($groups as $i => $g) {

            if ((int)$g[0] > 1)
                $ret .= self::$digits[$g[0]] . $this->wordSeparator;

            if ((int)$g[0] > 0)
                $ret .= "yüz" . $this->wordSeparator;

            if ((int)$g[1] > 0)
                $ret .= self::$digits_second[$g[1]] . $this->wordSeparator;

            if ((int)$g[2] > 0 && (($num_length === 4 && $i === 0 && (int)$g[2] <= 1) === false))
                $ret .= self::$digits[$g[2]] . $this->wordSeparator;

            if ((int)$g > 0)
                $ret .= self::$exponent[$g_index] . $this->wordSeparator;

            $g_index--;
        }

        return $ret;
    }
53915
public function eq($num) {
        if (!$this->_isValid) {
            return $this;
        }

        if ($this->_unsafeVar != $num) {
            $this->_isValid = false;
        }
        return $this;
    }
1188302
public function BaseCheck($base)
    {
        switch ($base) {
            case '256':
                return $this->genBytes();
            case '16':
                return $this->hex_chars;
            case '58':
                return $this->b58_chars;
            case '2':
                return $this->bin_chars;
            case '10':
                return $this->dec_chars;
            default:
                throw new \Exception('Unknown base parameter passed to Number::BaseCheck() function.  Value received was "' . var_export($base, true) . '".');
        }
    }
515537
public function increment(string $field, int $num) : int
        {
                return intval($this->_redis->hincrby($this->_key, $field, $num));
        }
607845
public function set_num_format($num_format) {

        $numbers = array();

        $numbers[1] = '0';
        $numbers[2] = '0.00';
        $numbers[3] = '#,##0';
        $numbers[4] = '#,##0.00';
        $numbers[11] = '0.00E+00';
        $numbers[12] = '# ?/?';
        $numbers[13] = '# ??/??';
        $numbers[14] = 'mm-dd-yy';
        $numbers[15] = 'd-mmm-yy';
        $numbers[16] = 'd-mmm';
        $numbers[17] = 'mmm-yy';
        $numbers[22] = 'm/d/yy h:mm';
        $numbers[49] = '@';

        if ($num_format !== 0 and in_array($num_format, $numbers)) {
            $flipped = array_flip($numbers);
            $this->properties['num_format'] = $flipped[$num_format];
        }
        if (!isset($numbers[$num_format])) {
            return;
        }

        $this->properties['num_format'] = $num_format;
    }
976905
protected function gerarNossoNumero()
    {
        return Util::numberFormatGeral($this->getNumero(), 11)
            . CalculoDV::bradescoNossoNumero($this->getCarteira(), $this->getNumero());
    }
648557
public static function dec2roman($num)
    {

        static $ones = array("", "i", "ii", "iii", "iv", "v", "vi", "vii", "viii", "ix");
        static $tens = array("", "x", "xx", "xxx", "xl", "l", "lx", "lxx", "lxxx", "xc");
        static $hund = array("", "c", "cc", "ccc", "cd", "d", "dc", "dcc", "dccc", "cm");
        static $thou = array("", "m", "mm", "mmm");

        if (!is_numeric($num)) {
            throw new Exception("dec2roman() requires a numeric argument.");
        }

        if ($num > 4000 || $num < 0) {
            return "(out of range)";
        }

        $num = strrev((string)$num);

        $ret = "";
        switch (mb_strlen($num)) {
            /** @noinspection PhpMissingBreakStatementInspection */
            case 4:
                $ret .= $thou[$num[3]];
            /** @noinspection PhpMissingBreakStatementInspection */
            case 3:
                $ret .= $hund[$num[2]];
            /** @noinspection PhpMissingBreakStatementInspection */
            case 2:
                $ret .= $tens[$num[1]];
            /** @noinspection PhpMissingBreakStatementInspection */
            case 1:
                $ret .= $ones[$num[0]];
            default:
                break;
        }

        return $ret;
    }
274530
public function shorten($num) {
		$str = '';

		while ($num > 0) {
			$str = $this->alphabet[($num % $this->base)] . $str;
			$num = (int) ($num / $this->base);
		}

		return $str;
	}