SkillAgentSearch skills...

Ocramius.util.Optional

:package: A PHP port of java.util.Optional as in the OpenJDK

Install / Use

/learn @Ocramius/Ocramius.util.Optional
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

ocramius\util\Optional

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Latest Unstable Version License

This package is a PHP port of the java.util.Optional class in the OpenJDK libraries.

Currently maintained by Niklas Schöllhorn, taken over 3rd March, 2019

You can find the API of java.lang.Optional in the Java 8 API docs.

Installation

composer require ocramius/optional

Differences with the Java implementation

Because of PHP's current limitations, I had to rewrite some bits of the Java implementation as follows:

  • Optional#empty() is named Optional#newEmpty(), because empty is a reserved PHP keyword
  • type-safety is not ensured at any time: generics have simply been stripped from the Optional implementation. This may change in future, but I don't plan to do it right now.
  • Optional#toString() is named Optional#__toString() in accordance to PHP magic methods naming
  • Consumer, Predicate, Function and Supplier arguments are simply callable, for simplicity and flexibility.

License

Since this library is a direct port of the OpenJDK sources, I have to keep the original license in place, which is GPLv2 + ClassPath exceptions.

Related Skills

View on GitHub
GitHub Stars27
CategoryDevelopment
Updated3y ago
Forks4

Languages

PHP

Security Score

60/100

Audited on Jan 28, 2023

No findings