2017 © Pedro PelĂĄez
 

library php-java-optional

Full implementation of Java8 Optional for PHP

image

serhatozdal/php-java-optional

Full implementation of Java8 Optional for PHP

  • Saturday, April 14, 2018
  • by serhatozdal
  • Repository
  • 1 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

serhatozdal/php-java-optional

Full implementation of JAVA8 Optional for PHP, (*1)

Build Status Latest Stable Version Latest Unstable Version GitHub license, (*2)

Usage

// ofEmpty refers Optional#empty() in java
// It is renamed as ofEmpty() because of empty() is reserved by PHP 
Optional::ofEmpty()->isPresent(); // false

Optional::of("value")->orElse("elseValue"); // value

Optional::ofEmpty()->orElseThrow(function () { throw .... }); // throws exception

Optional::ofEmpty()->filter(function ($a) { return (int) $a; }); // function is not executed

Optional::of(5)->map(function ($a) { return $a * 2; })->get(); // returns 10

Optional::ofEmpty()->orElseGet(function () { return 10; }); // returns 10

Installation

composer require serhatozdal/php-java-optional:1.0

Resources

The Versions

14/04 2018

dev-master

9999999-dev https://github.com/serhatozdal/php-java-optional

Full implementation of Java8 Optional for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.5.0

 

The Development Requires

by Serhat ÖZDAL

php optional java optional php java optional

14/04 2018

1.0

1.0.0.0 https://github.com/serhatozdal/php-java-optional

Full implementation of Java8 Optional for PHP

  Sources   Download

Apache-2.0

The Requires

  • php >=5.5.0

 

The Development Requires

by Serhat ÖZDAL

php optional java optional php java optional