Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ncrypthic/functionalphp
Basic functional programming support for PHP
https://github.com/ncrypthic/functionalphp
Last synced: 13 days ago
JSON representation
Basic functional programming support for PHP
- Host: GitHub
- URL: https://github.com/ncrypthic/functionalphp
- Owner: ncrypthic
- Created: 2019-02-24T03:26:55.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-02-24T03:49:00.000Z (over 5 years ago)
- Last Synced: 2024-10-11T18:32:46.949Z (about 1 month ago)
- Language: PHP
- Size: 13.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Functional PHP
## Installation
```
$ composer require ncrypthic/functionalphp
```## Usage
1. Monads
1. [Option](#option)
2. [Execute](#execute)
3. [Match](#match)## Option
```php
$maybeNull = Maybe($val)->match()
->case(Some(1), function($val) {
})
->case(None(), function($val) {
})
->val();
```## Execute
```php
$tryExecute = Execute($callable)->match()
->case(Success(1), function($val) {
})
->case(Failure(), function($val) {
})
->val();
```## Match
```php
$tryExecute = Execute($callable)->match()
->case(Success(1), function($val) {
})
->case(Failure(), function($val) {
})
->val();
```