Converti un nombre en toute lettre

@param integer $p_curr
@param integer $p_decimal
@param integer $p_fraction
@param integer $p_convertFraction

@return string
505424
public function toCurrencyWords($p_curr, $p_decimal, $p_fraction = false, $p_convertFraction = true)
    {
        $p_curr = strtoupper($p_curr);
        if ($p_curr == '') {
            $p_curr = $this->getDefaultCurrency();
        }
        $curr_names = $this->getCurrencyName($p_curr);
        $ret = trim($this->toWords($p_decimal));
        $lev = ($p_decimal == 1) ? 0 : 1;
        if ($lev > 0) {
            if (count($curr_names[0]) > 1) {
                $ret .= $this->getSeparator() . $curr_names[0][$lev];
            } else {
                $ret .= $this->getSeparator() . $curr_names[0][0] . $this->getPlural();
            }
        } else {
            $ret .= $this->getSeparator() . $curr_names[0][0];
        }
        if ($p_fraction !== false) {
            if ($p_convertFraction) {
                $ret .= $this->getSeparator() . $this->getAnd() . $this->getSeparator() .
                        trim($this->toWords($p_fraction));
            } else {
                $ret .= $this->getSeparator() . $this->getAnd() . $this->getSeparator() . $p_fraction;
            }
            $lev = ($p_fraction == 1) ? 0 : 1;
            if ($lev > 0) {
                if (count($curr_names[1]) > 1) {
                    $ret .= $this->getSeparator() . $curr_names[1][$lev];
                } else {
                    $ret .= $this->getSeparator() . $curr_names[1][0] . 's';
                }
            } else {
                $ret .= $this->getSeparator() . $curr_names[1][0];
            }
        }
        return $ret;
    }
1000509
public function toCurrencyWords($currency, $decimal, $fraction = null)
    {
        $currency = strtoupper($currency);

        if (!array_key_exists($currency, static::$currencyNames)) {
            throw new NumberToWordsException(
                sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))
            );
        }

        $currencyNames = static::$currencyNames[$currency];

        $return = '';
        if ($decimal > 0 || (0 === $decimal && $this->options->isShowDecimalIfZero())) {
            if ($currencyNames[0][0] === 2) {
                static::$ten = array_reverse(static::$ten);
            }

            $return .= $this->toWords($decimal) .' '. $this->morph($decimal, $currencyNames[0][1], $currencyNames[0][2], $currencyNames[0][3]);

            if ($currencyNames[0][0] === 2) {
                static::$ten = array_reverse(static::$ten);
            }
        }

        if (null !== $fraction) {
            if ($currencyNames[1][0] === 2) {
                static::$ten = array_reverse(static::$ten);
            }

            if ($this->options->isConvertFraction()) {
                $return .= ' ' . $this->toWords($fraction) . ' ' . $this->morph($fraction, $currencyNames[1][1], $currencyNames[1][2], $currencyNames[1][3]);
            } else {
                $return .= ' ' . $fraction . ' ' . $this->morph($fraction, $currencyNames[1][1], $currencyNames[1][2], $currencyNames[1][3]);
            }

            if ($currencyNames[1][0] === 2) {
                static::$ten = array_reverse(static::$ten);
            }
        }

        if (null === $fraction && $this->options->isShowFractionIfZero()) {
            if ($currencyNames[1][0] === 2) {
                static::$ten = array_reverse(static::$ten);
            }

            if ($this->options->isConvertFractionIfZero()) {
                $return .= ' ' . $this->zero . ' ' . $this->morph($fraction, $currencyNames[1][1], $currencyNames[1][2], $currencyNames[1][3]);
            } else {
                $return .= ' 00 ' . $this->morph($fraction, $currencyNames[1][1], $currencyNames[1][2], $currencyNames[1][3]);
            }

            if ($currencyNames[1][0] === 2) {
                static::$ten = array_reverse(static::$ten);
            }
        }

        return $return;
    }
1309916
public function toCurrencyWords($currency, $decimal, $fraction = null)
    {
        $negative = 0;
        $ret = [];
        $noDecimals = false;

        /**
         * Negative ?
         * We can lose the '-' sign if we do the
         * check after number_format() call (i.e. -0.01)
         */
        if (substr($decimal, 0, 1) == '-') {
            $decimal = -$decimal;
            $negative = 1;
        }

        /**
         * Removes leading zeros, spaces, decimals etc.
         * Adds thousands separator.
         */
        $num = number_format($decimal, 0, '', '');

        /**
         * Checking if given currency exists in driver.
         * If not, use default currency
         */
        $currency = strtoupper($currency);
        if (!isset(self::$currencyNames[$currency])) {
            throw new NumberToWordsException(
                sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))
            );
        }

        /**
         * Currency names and plural
         */
        $currencyNames = self::$currencyNames[$currency];

        if ($num > 0) {
            /**
             * Word representation of decimal
             */
            $ret[] = $this->toWords($num);

            /**
             * Special case.
             */
            if (substr($num, -6) == '000000') {
                $ret[] = trim($this->currencySeparator);
            }

            /**
             * Testing plural. Adding currency name
             */
            if ($num > 1) {
                $ret[] = $currencyNames[0][1];
            } else {
                $ret[] = $currencyNames[0][0];
            }
        }

        /**
         * Test if fraction was given and != 0
         */
        $fraction = (int) $fraction;
        if ($fraction) {

            /**
             * Removes leading zeros, spaces, decimals etc.
             * Adds thousands separator.
             */
            $num = number_format($fraction, 0, '.', '.');

            if ($num < 0 || $num > 99) {
                throw new NumberToWordsException('Fraction out of range.');
            }

            if (count($ret)) {
                $ret[] = trim($this->separator);
            } else {
                $noDecimals = true;
            }


            $ret[] = $this->toWords($num);

            if ($num > 1) {
                $ret[] = $currencyNames[1][1];
            } else {
                $ret[] = $currencyNames[1][0];
            }

            if ($noDecimals) {
                $ret[] = trim($this->currencySeparator);
                $ret[] = $currencyNames[0][0];
            }
        }

        if ($negative) {
            $ret[] = $this->minus;
        }

        return implode(' ', $ret);
    }
603423
public function value(float $value, int $decimal_points = null): string
    {
        if (is_null($decimal_points)) {
            return $value;
        }

        return $this->decimal($value, $decimal_points);
    }
196553
public static function convertToHumanReadable($bytes, $decimals = 2)
    {
        $factor = floor((strlen($bytes) - 1) / 3);

        $value = sprintf("%.{$decimals}f", $bytes / pow(1024, $factor));
        $unit = static::$sizes[(string)$factor];

        return sprintf('%g %s', $value, $unit);
    }
1037499
public function getAmountCents()
    {
        if ($this->getNotForPayment()) {
            return 'XX';
        }
        $amount = $this->getAmount();
        $francs = intval($amount);
        $cents = round(($amount - $francs) * 100);
        return str_pad($cents, 2, '0', STR_PAD_LEFT);
    }
1248204
public function toWords($p_num, $p_power = 0, $p_powsuffix = '')
    {
        $ret = '';
        // négatif ?
        if (substr($p_num, 0, 1) == '-') {
            $ret = $this->getSeparator() . $this->getMinus();
            $p_num = substr($p_num, 1);
        }
        // on enlève les chiffres inutiles de gauche
        $p_num = trim($p_num);
        $p_num = preg_replace('/^0+/', '', $p_num);
        if (strlen($p_num) > 3) {
            $maxp = strlen($p_num)-1;
            $curp = $maxp;
            for ($p = $maxp; $p > 0; --$p) {
                if ($this->hasExponent($p)) {
                    // send substr from $curp to $p
                    $snum = substr($p_num, $maxp - $curp, $curp - $p + 1);
                    $snum = preg_replace('/^0+/', '', $snum);
                    if ($snum !== '') {
                        $exponent  = $this->getExponent($p_power);
                        $cursuffix = $exponent[count($exponent)-1];
                        if ($p_powsuffix != '') {
                            $cursuffix .= $this->getSeparator() . $p_powsuffix;
                        }
                        $ret .= $this->toWords($snum, $p, $cursuffix);
                    }
                    $curp = $p - 1;
                    continue;
                }
            }
            $p_num = substr($p_num, $maxp - $curp, $curp - $p + 1);
            if ($p_num == 0) {
                return $ret;
            }
        } else {
            if ($p_num == 0 || $p_num == '') {
                return $this->getSeparator() . $this->getDigit(0);
            }
        }
        $h = $t = $d = 0;
        switch (strlen($p_num)) {
            case 3:
                $h = (int)substr($p_num, -3, 1);
                // no break
            case 2:
                $t = (int)substr($p_num, -2, 1);
                // no break
            case 1:
                $d = (int)substr($p_num, -1, 1);
                break;
            case 0:
                return;
                break;
        }
        if ($h) {
            $ret .= $this->getSeparator() . $this->getDigit($h) . $this->getSeparator() . 'hundred';
        }
        switch ($t) {
            case 9:
            case 7:
            case 6:
                $ret .= $this->getSeparator() . $this->getDigit($t) . 'ty';
                break;
            case 8:
                $ret .= $this->getSeparator() . 'eighty';
                break;
            case 5:
                $ret .= $this->getSeparator() . 'fifty';
                break;
            case 4:
                $ret .= $this->getSeparator() . 'forty';
                break;
            case 3:
                $ret .= $this->getSeparator() . 'thirty';
                break;
            case 2:
                $ret .= $this->getSeparator() . 'twenty';
                break;
            case 1:
                switch ($d) {
                    case 0:
                        $ret .= $this->getSeparator() . 'ten';
                        break;
                    case 1:
                        $ret .= $this->getSeparator() . 'eleven';
                        break;
                    case 2:
                        $ret .= $this->getSeparator() . 'twelve';
                        break;
                    case 3:
                        $ret .= $this->getSeparator() . 'thirteen';
                        break;
                    case 4:
                    case 6:
                    case 7:
                    case 9:
                        $ret .= $this->getSeparator() . $this->getDigit($d) . 'teen';
                        break;
                    case 5:
                        $ret .= $this->getSeparator() . 'fifteen';
                        break;
                    case 8:
                        $ret .= $this->getSeparator() . 'eighteen';
                        break;
                }
                break;
        }
        if ($t != 1 && $d > 0) {
            if ($t > 1) {
                $ret .= '-' . $this->getDigit($d);
            } else {
                $ret .= $this->getSeparator() . $this->getDigit($d);
            }
        }
        if ($p_power > 0) {
            if ($this->hasExponent($p_power)) {
                $lev = $this->getExponent($p_power);
            }
            if (!isset($lev) || !is_array($lev)) {
                return null;
            }
            $ret .= $this->getSeparator() . $lev[0];
        }
        if ($p_powsuffix != '') {
            $ret .= $this->getSeparator() . $p_powsuffix;
        }

        return $ret;
    }
155484
public static function parseByDecimal($money, $forceCurrency = null, Currencies $currencies = null)
    {
        $parser = new DecimalMoneyParser($currencies ?: static::getCurrencies());

        return self::parseByParser($parser, $money, $forceCurrency);
    }
478240
public function decimal($values, string $currency = null, int $decimal_points = 2): string
    {
        [$className, $value] = $this->classAndValue($values, $currency);

        return (new $className)->decimal($value, $decimal_points);
    }
461448
public static function dttm2br($var,$separador="/"){
			if(preg_match('/([0-9]{4})\-([0-9]{2})\-([012][0-9]|3[01])[ ]([0-9]{2}):([0-9]{2}):([0-9]{2})/', $var, $array)){
				$dt = self::checkDtbr($array[3], $array[2], $array[1],$separador);
				if($dt && ($array[4] != '00' || $array[5] != '00'))
					$dt .= '  '.$array[4].':'.$array[5];
				return $dt;
			}
		}
863909
public function hyphenateWord($word, $currptr)
	{
		// Do everything inside this function in utf-8
		// Don't hyphenate web addresses
		if (preg_match('/^(http:|www\.)/', $word)) {
			return -1;
		}

		$ptr = -1;

		if (!$this->dictionaryLoaded) {
			$this->loadDictionary();
		}

		if (!in_array($this->mpdf->SHYlang, $this->mpdf->SHYlanguages)) {
			return -1;
		}

		// If no pattern loaded or not the best one
		if (!$this->patternsLoaded()) {
			$this->loadPatterns();
		}

		if ($this->mpdf->usingCoreFont) {
			$word = mb_convert_encoding($word, 'UTF-8', $this->mpdf->mb_enc);
		}

		$prepre = '';
		$postpost = '';
		$startpunctuation = "\xc2\xab\xc2\xbf\xe2\x80\x98\xe2\x80\x9b\xe2\x80\x9c\xe2\x80\x9f";
		$endpunctuation = "\xe2\x80\x9e\xe2\x80\x9d\xe2\x80\x9a\xe2\x80\x99\xc2\xbb";

		if (preg_match('/^(["\'' . $startpunctuation . '])+(.{' . $this->mpdf->SHYcharmin . ',})$/u', $word, $m)) {
			$prepre = $m[1];
			$word = $m[2];
		}

		if (preg_match('/^(.{' . $this->mpdf->SHYcharmin . ',})([\'\.,;:!?"' . $endpunctuation . ']+)$/u', $word, $m)) {
			$word = $m[1];
			$postpost = $m[2];
		}

		if (mb_strlen($word, 'UTF-8') < $this->mpdf->SHYcharmin) {
			return -1;
		}

		$success = false;
		$preprelen = mb_strlen($prepre);

		if (isset($this->words[mb_strtolower($word)])) {
			foreach ($this->words[mb_strtolower($word)] as $i) {
				if (($i + $preprelen) >= $currptr) {
					break;
				}

				$ptr = $i + $preprelen;
				$success = true;
			}
		}

		if (!$success) {
			$text_word = '_' . $word . '_';
			$word_length = mb_strlen($text_word, 'UTF-8');
			$text_word = mb_strtolower($text_word, 'UTF-8');
			$hyphenated_word = [];

			$numbers = [
				'0' => true,
				'1' => true,
				'2' => true,
				'3' => true,
				'4' => true,
				'5' => true,
				'6' => true,
				'7' => true,
				'8' => true,
				'9' => true
			];

			for ($position = 0; $position <= ($word_length - $this->mpdf->SHYcharmin); $position++) {
				$maxwins = min($word_length - $position, $this->mpdf->SHYcharmax);
				for ($win = $this->mpdf->SHYcharmin; $win <= $maxwins; $win++) {
					if (isset($this->patterns[mb_substr($text_word, $position, $win, 'UTF-8')])) {
						$pattern = $this->patterns[mb_substr($text_word, $position, $win, 'UTF-8')];
						$digits = 1;
						$pattern_length = mb_strlen($pattern, 'UTF-8');

						for ($i = 0; $i < $pattern_length; $i++) {
							$char = $pattern[$i];
							if (isset($numbers[$char])) {
								$zero = $i === 0 ? $position - 1 : $position + $i - $digits;
								if (!isset($hyphenated_word[$zero]) || $hyphenated_word[$zero] !== $char) {
									$hyphenated_word[$zero] = $char;
								}
								$digits++;
							}
						}
					}
				}
			}

			for ($i = $this->mpdf->SHYleftmin; $i <= (mb_strlen($word, 'UTF-8') - $this->mpdf->SHYrightmin); $i++) {
				if (isset($hyphenated_word[$i]) && $hyphenated_word[$i] % 2 !== 0) {
					if (($i + $preprelen) > $currptr) {
						break;
					}
					$ptr = $i + $preprelen;
				}
			}
		}

		return $ptr;
	}
1229797
public function toCurrencyWords($currency, $decimal, $fraction = null)
    {
        $currency = strtoupper($currency);

        if (!isset(Dictionary::$currencyNames[$currency])) {
            throw new NumberToWordsException(
                sprintf('Currency "%s" is not available for "%s" language', $currency, get_class($this))
            );
        }

        $words = [];
        $currencyNouns = Dictionary::$currencyNames[$currency];

        $words[] = $this->toWords($decimal, $currencyNouns[0]);

        if ($fraction !== null) {
            $words[] = Dictionary::$and;
            $words[] = $this->toWords($fraction, $currencyNouns[1]);
        }

        return implode(' ', $words);
    }
473612
protected function _decipher(&$Xl, &$Xr)
    {
        if ($Xl < 0) {
            $Xl += 4294967296;
        }
        if ($Xr < 0) {
            $Xr += 4294967296;
        }

        for ($i = 17; $i > 1; --$i) {
            $temp = $Xl ^ $this->_P[$i];
            if ($temp < 0) {
                $temp += 4294967296;
            }

            $Xl = fmod((fmod($this->_S[0][($temp >> 24) & 255]
                             + $this->_S[1][($temp >> 16) & 255], 4294967296)
                        ^ $this->_S[2][($temp >> 8) & 255])
                       + $this->_S[3][$temp & 255], 4294967296) ^ $Xr;
            $Xr = $temp;
        }

        $Xr = $this->_binxor($Xl, $this->_P[1]);
        $Xl = $this->_binxor($temp, $this->_P[0]);
    }
917048
public function formatPrice(float $price, $baseCurrency = null, $targetCurrency = null, $locale = null, $quantity = 1) : string
    {
        return $this->helper->convertAndFormat($price, $baseCurrency, $targetCurrency, $quantity, $locale);
    }
262590
private function convert(Money $money, $divisor): float
    {
        return (float) number_format(($money->getAmount() / $divisor), 2, '.', '');
    }
367949
public static function formataCPFCNPJ($str)
    {
        $str = preg_replace('![^\d]!', '', $str);
        if (11 == strlen($str) || 14 > strlen($str)) {
            $str = CPF::formatar($str);
        } elseif (14 <= strlen($str)) {
            $str = CNPJ::formatar($str);
        }

        return $str;
    }
785375
public function formatCurrency($value, $currency, $precision=2)
    {
        $newValue = trim($value, " \0\x0B$currency");
        if (!is_numeric($newValue)) {
            return $value;
        }

        $pattern = $this->getPattern($value, 'Intl_NumberFormatCurrency');

        if ($newValue == round($newValue)) {
            // if no fraction digits available, don't show any
            $value = $this->formatNumberWithPattern($pattern, $newValue, 0, 0);
        } else {
            // show given count of fraction digits otherwise
            $value = $this->formatNumberWithPattern($pattern, $newValue, $precision, $precision);
        }

        return str_replace('¤', $currency, $value);
    }