PHP code example of brekitomasson / laravel-support-helpers

1. Go to this page and download the library: Download brekitomasson/laravel-support-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/ */

    

brekitomasson / laravel-support-helpers example snippets


$number = new \BrekiTomasson\Support\Number('234.22');
$number->add(3)->over(2)->toNumber();
// = 118.61

num('234.22')->add(3)->over(2)->toNumber();
// = 118.61

use BrekiTomasson\Support\Num;

Num::percentOf(13, 49);
// = 26.530612244898

num(234.56)->decimal()->toNumber()
// = 56

num(39234)->factors()
// = [2, 3, 6, 13, 26, 39, 78, 503, 1006, 1509, 3018, 6539, 13078, 19617]

num(39)->greaterThan(50)
// = false

num(50)->inRange(20, 80)
// = true

num(10)->inRange(5, 10, false)
// = false

num(234.56)->integer()->toNumber()
// = 234

num(39)->lessThan(50)
// = true

num(100)->over(5)->toNumber()
// = 20

num(30)->percentOf(600)->toNumber()
// = 5

num(19.2342)->roundToPart(2)->toNumber()
// = 19

num(19.2342)->roundToPart(3)->toNumber()
// = 19.333333333333

num(19.2342)->roundToPart(10)->toNumber()
// = 19.2

num(10)->withinRange(13, 2)
// = false
// Since 10 is not within the range 11-15. 

num(19)->withinRange(15, 5)
// = true
// Since 19 is within the range 10-20.