PHP code example of jinomdeveloper / helpers

1. Go to this page and download the library: Download jinomdeveloper/helpers library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

jinomdeveloper / helpers example snippets


use Jinom\Helpers\Facades\Helpers;

// Price cho $taxService->basePrice;    // 100000 (original price before tax)
echo $taxService->tax;          // 11000 (tax amount)
echo $taxService->taxedPrice;   // 111000 (total price with tax)

use Jinom\Helpers\Facades\Helpers;

// Base price without tax
$taxService = Helpers::tax(100000, false);

echo $taxService->basePrice;    // 100000 (original price)
echo $taxService->tax;          // 11000 (calculated tax)
echo $taxService->taxedPrice;   // 111000 (total price with tax)

use Jinom\Helpers\Facades\Helpers;

echo Helpers::rupiah(1000000);     // "Rp 1.000.000"
echo Helpers::rupiah(150000);      // "Rp 150.000"
echo Helpers::rupiah(1500.75);     // "Rp 1.501" (rounded to nearest integer)

use Jinom\Helpers\Facades\Helpers;

echo Helpers::terbilang(1000000);  // "Satu Juta Rupiah"
echo Helpers::terbilang(150000);   // "Seratus Lima Puluh Ribu Rupiah"
echo Helpers::terbilang(25);       // "Dua Puluh Lima Rupiah"

use Jinom\Helpers\Facades\Helpers;

echo Helpers::rupiah_to_number("Rp 1.000.000");    // 1000000
echo Helpers::rupiah_to_number("Rp 150.000");      // 150000
echo Helpers::rupiah_to_number("1.500,75");        // 1500.75
echo Helpers::rupiah_to_number("(Rp 50.000)");     // -50000 (negative)

use Jinom\Helpers\Facades\Helpers;

echo Helpers::to_e164("081234567890");      // "+6281234567890"
echo Helpers::to_e164("0812-3456-7890");    // "+6281234567890"
echo Helpers::to_e164("62812345678");       // "+62812345678"
echo Helpers::to_e164("+6281234567890");    // "+6281234567890"

// With custom country code
echo Helpers::to_e164("081234567890", "1"); // "+181234567890"

use Jinom\Helpers\Helpers;
use Jinom\Helpers\Services\TaxService;

// Direct tax calculation
$taxService = new TaxService(111000, true);

// Using the main class
$helpers = new Helpers();
$taxService = $helpers::tax(111000, true);

// Currency formatting
echo $helpers::rupiah(1000000);

use Jinom\Helpers\Facades\Helpers;

// Product price displayed to customer (roduct Price: " . Helpers::rupiah($tax->basePrice);     // "Rp 500.000"
echo "Tax (PPN 11%): " . Helpers::rupiah($tax->tax);          // "Rp 55.000"
echo "Total Price: " . Helpers::rupiah($tax->taxedPrice);     // "Rp 555.000"
echo "Amount in Words: " . Helpers::terbilang($tax->taxedPrice); // "Lima Ratus Lima Puluh Lima Ribu rupiah"

use Jinom\Helpers\Facades\Helpers;

// Customer input from form
$customerInput = [
    'amount' => 'Rp 1.500.000',
    'phone' => '0812-3456-7890'
];

// Parse and process
$amount = Helpers::rupiah_to_number($customerInput['amount']);  // 1500000
$phone = Helpers::to_e164($customerInput['phone']);           // "+6281234567890"

// Calculate with tax
$tax = Helpers::tax($amount, false);
echo "Final amount: " . Helpers::rupiah($tax->taxedPrice);    // "Rp 1.665.000"
echo "Amount in words: " . Helpers::terbilang($tax->taxedPrice);
echo "Contact: " . $phone;

use Jinom\Helpers\Facades\Helpers;

$items = [
    ['name' => 'Product A', 'price' => 100000],
    ['name' => 'Product B', 'price' => 250000],
];

$subtotal = 0;
$totalTax = 0;

foreach ($items as $item) {
    $tax = Helpers::tax($item['price'], false);
    
    echo $item['name'] . ": " . Helpers::rupiah($tax->basePrice) . "\n";
    
    $subtotal += $tax->basePrice;
    $totalTax += $tax->tax;
}

echo "Subtotal: " . Helpers::rupiah($subtotal) . "\n";        // "Rp 350.000"
echo "Tax (PPN 11%): " . Helpers::rupiah($totalTax) . "\n";   // "Rp 38.500"
echo "Total: " . Helpers::rupiah($subtotal + $totalTax) . "\n"; // "Rp 388.500"

use Jinom\Helpers\Facades\Helpers;

// All methods available statically
$taxService = Helpers::tax(100000, false);
$formatted = Helpers::rupiah(100000);