Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/munusphp/munus
Power of object-oriented programming with the elegance of functional programming in PHP.
https://github.com/munusphp/munus
functional-programming hacktoberfest immutable-collections immutable-objects object-functional php stream
Last synced: 3 months ago
JSON representation
Power of object-oriented programming with the elegance of functional programming in PHP.
- Host: GitHub
- URL: https://github.com/munusphp/munus
- Owner: munusphp
- License: mit
- Created: 2019-10-24T17:01:26.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-29T07:58:11.000Z (6 months ago)
- Last Synced: 2024-05-29T20:36:30.733Z (6 months ago)
- Topics: functional-programming, hacktoberfest, immutable-collections, immutable-objects, object-functional, php, stream
- Language: PHP
- Homepage: https://munusphp.github.io/
- Size: 502 KB
- Stars: 171
- Watchers: 11
- Forks: 12
- Open Issues: 6
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# Munus
[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%208.1-8892BF.svg)](https://php.net/)
[![github action](https://github.com/munusphp/munus/workflows/build/badge.svg)](https://github.com/munusphp/munus/actions?query=workflow%3Abuild)
[![Latest Stable Version](https://poser.pugx.org/munusphp/munus/v/stable?format=flat)](https://packagist.org/packages/munusphp/munus)
[![codecov](https://codecov.io/gh/munusphp/munus/branch/master/graph/badge.svg)](https://codecov.io/gh/munusphp/munus)
[![Total Downloads](https://poser.pugx.org/munusphp/munus/downloads?format=flat)](https://packagist.org/packages/munusphp/munus)
![GitHub](https://img.shields.io/github/license/munusphp/munus)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](https://munusphp.github.io/docs/start)**
Due to the lack of generic types, Munus achieves genericity with the help of [PHPStan](https://phpstan.org/blog/generics-in-php-using-phpdocs) `template` annotation.
Stream example: find the sum of the first ten squares of even numbers
```php
Stream::from(1)
->filter(fn($n) => $n%2===0)
->map(fn($n) => $n**2)
->take(10)
->sum();
```Other examples:
```php
/** @var Stream $stream */
$stream = Stream::range(1, 10)->map(function(int $int): int {return $int * 5});/** @var Option $option */
$option = Option::of(domainOperation());/** @return Either */
function domainOperation(): Either {}/** @var TryTo $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](https://www.vavr.io/)
## License
Munus is released under the MIT Licence. See the bundled LICENSE file for details.
## Author
[@ArkadiuszKondas](https://twitter.com/ArkadiuszKondas)