PHP code example of devshed-io / arithmatic

1. Go to this page and download the library: Download devshed-io/arithmatic 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/ */

    

devshed-io / arithmatic example snippets


Arithmatic
    ::start(5)
    ->add(5)
    ->subtract(7);
    ->divide(2);
    ->multiply(7)
    ->output();

Arithmatic
    ::start(10)
    ->when(true, fn (Arithmatic $calculation) => $calculation->subtract(5))->output();

Arithmatic
    ::start(10)
    ->when(
        false,
        fn (Arithmatic $calculation) => $calculation->subtract(5),
        fn (Arithmatic $calculation) => $calculation->add(5), // This will run...
    )
    ->output();

Arithmatic
    ::make(10)
    ->run([
        'add' => 5,
        'divide' => 2,
        'round'
    ])
    ->output(); // 3
bash
docker-compose run --rm php vendor/bin/phpunit --testdox