Skip to content
Power of object-oriented programming with the elegance of functional programming in PHP.
PHP
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github/workflows Update php.yml Dec 8, 2019
src Allow to map Map keys and values in separate methods (#32) Dec 8, 2019
tests Allow to map Map keys and values in separate methods (#32) Dec 8, 2019
.gitignore Install and configure docusaurus Nov 18, 2019
.php_cs POC: implement Either and Try Oct 25, 2019
LICENSE Initial commit Oct 24, 2019
README.md Update readme badges Dec 8, 2019
buddy.yml Update packages in buddy docker Oct 31, 2019
composer.json Transfer repository to munusphp orgranization Nov 18, 2019
composer.lock Downgrade package-versions for comp with php 7.2 Nov 28, 2019
phpunit.xml
psalm.xml POC: implement Either and Try Oct 25, 2019

README.md

Munus

Minimum PHP Version buddy pipeline github action Latest Stable Version Maintainability Total Downloads GitHub

Power of object-oriented programming with the elegance of functional programming. Increase the robustness with reduced amount of code.

At the moment, in the experimental phase.

Documentation

Due to the lack of generic types, Munus achieves genericity with the help of Psalm template annotation.

Stream example: find the sum of the first ten squares of even numbers

Stream::from(1)
    ->filter(fn($n) => $n%2===0)
    ->map(fn($n) => $n**2)
    ->take(10)
    ->sum();

Other examples:

/** @var Stream<int> $stream */
$stream = Stream::range(1, 10)->map(function(int $int): int {return $int * 5});

/** @var Option<Success> $option */
$option = Option::of(domainOperation());

/** @return Either<Failure,Success> */
function domainOperation(): Either {}

/** @var TryTo<Result> $result */
$result = TryTo::run(function(){throw new \DomainException('use ddd');});
$result->getOrElse(new Result())

The goal is to help achieve: Psalm was able to infer types for 100% of the codebase

Features

Values:

  • TryTo
  • Either
  • Option
  • Lazy

Collections:

  • Set
  • Stream (implemented as lazy linked list)
  • GenericList (implemented as immutable linked list)
  • Iterator

Other:

  • Tuple

Roadmap

  • Pattern matching
  • Property checking

Inspiration

This library is inspired by vavr.io

License

Munus is released under the MIT Licence. See the bundled LICENSE file for details.

Author

@ArkadiuszKondas

You can’t perform that action at this time.