munus

Power of object-oriented programming with the elegance of functional programming in PHP.

Github星跟踪图

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

主要指标

概览
名称与所有者munusphp/munus
主编程语言PHP
编程语言PHP (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2019-10-24 17:01:26
推送于2024-12-08 18:00:52
最后一次提交2024-12-08 18:52:18
发布数25
最新版本名称0.17.0 (发布于 )
第一版名称0.1.0-rc.1 (发布于 )
用户参与
星数168
关注者数9
派生数12
提交数137
已启用问题?
问题数15
打开的问题数2
拉请求数92
打开的拉请求数0
关闭的拉请求数6
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?