ncrypthic / functionalphp
Functional php primitives
1.0.1
2019-02-24 03:47 UTC
Requires (Dev)
- behat/behat: ^3.5
- phpunit/phpunit: ^8.0
This package is auto-updated.
Last update: 2024-12-24 15:56:29 UTC
README
Installation
$ composer require ncrypthic/functionalphp
Usage
Option
<?php 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();
Execute
<?php 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();
Match
<?php 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();