Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

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

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();
```