ÿØÿàJFIFHHÿÛC     ÿÛC  ÿÂ"ÿÄÿÄÿÚ ±5¬€ÿÄàÿÚÿÄÀÿÚ?ÿÄÀÿÚ?ÿÄàÿÚ?ÿÄàÿÚ?!ÿÚ ÿÄÀÿÚ?ÿÄÀÿÚ?ÿÄàÿÚ?ÿÙ Donat Was Here
KENFOXXSHELL
Server IP : 160.25.81.117  /  Your IP : 216.73.216.137
Web Server : Apache/2
System : Linux sv05.hilab.cloud 3.10.0-1160.119.1.el7.x86_64 #1 SMP Tue Jun 4 14:43:51 UTC 2024 x86_64
User : bellizen ( 1045)
PHP Version : 7.2.34
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /home/bellizen/public_html/vendor/gabrielelana/byte-units/src/ByteUnits/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ HOME SHELL ]     

Current File : /home/bellizen/public_html/vendor/gabrielelana/byte-units/src/ByteUnits/Formatter.php
<?php

namespace ByteUnits;

class Formatter
{
    private $converter;
    private $precision;

    public function __construct($converter, $precision)
    {
        $this->converter = $converter;
        $this->precision = $precision;
    }

    public function precision()
    {
        return $this->precision;
    }

    public function format($numberOfBytes, $howToFormat)
    {
        $precision = $this->precisionFrom($howToFormat);
        $byteUnit = $this->byteUnitToFormatTo($numberOfBytes, $howToFormat);
        return $this->formatInByteUnit($numberOfBytes, $byteUnit, $precision);
    }

    private function precisionFrom($howToFormat)
    {
        if (is_integer($howToFormat)) {
            return $howToFormat;
        }
        if (is_string($howToFormat)) {
            if (preg_match('/^.*\/(?<precision>0*)$/', $howToFormat, $matches)) {
                return strlen($matches['precision']);
            }
            if (preg_match('/^.*\/(?<precision>\d+)$/', $howToFormat, $matches)) {
                return intval($matches['precision']);
            }
        }
        return $this->precision;
    }

    private function byteUnitToFormatTo($numberOfBytes, $howToFormat)
    {
        if (is_string($howToFormat)) {
            if (preg_match("/^(?P<unit>[^\/]+)(?:\/.*$)?/i", $howToFormat, $matches)) {
                if ($this->converter->isKnownUnit($matches['unit'])) {
                    return $this->converter->normalizeNameOfUnit($matches['unit']);
                }
            }
        }
        return $this->converter->normalUnitFor($numberOfBytes);
    }

    private function formatInByteUnit($numberOfBytes, $byteUnit, $precision)
    {
        $scaled = $this->converter->scaleToUnit($numberOfBytes, $byteUnit);
        if($byteUnit == null) $byteUnit = "B";
        if ($this->converter->isBaseUnit($byteUnit)) {
            return sprintf("%d%s", $scaled, $byteUnit);
        }
        return sprintf("%.{$precision}f%s", $scaled, $byteUnit);
    }
}

Anon7 - 2022
AnonSec Team