PHP code example of ncrypthic / functionalphp

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

    

ncrypthic / functionalphp example snippets



use LLA\Functional\Maybe;
use LLA\Functional\Some;
use LLA\Functional\None;

// ...
// $val = <someValue>
$maybeNull = Maybe($val)->match()
  ->case(Some(1), function($val) {
  })
  ->case(None(), function($val) {
  })
  ->val();


use LLA\Functional\Execute;
use LLA\Functional\Success;
use LLA\Functional\Failure;

// ...
// $callable = <someValue>
$tryExecute = Execute($callable)->match()
  ->case(Success(1), function($val) {
  })
  ->case(Failure(), function($val) {
  })
  ->val();


use LLA\Functional\Execute;
use LLA\Functional\Success;
use LLA\Functional\Failure;

// ...
// $callable = <someValue>
$tryExecute = Execute($callable)->match()
  ->case(Success(1), function($val) {
  })
  ->case(Failure(), function($val) {
  })
  ->val();