Created
January 30, 2016 17:49
-
-
Save dana-ross/84efc256f612d95b340a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use DaveRoss\FunctionalProgrammingUtils\Maybe as Maybe; | |
$good = Maybe::of( json_decode( '{ "label": "This is valid JSON", "value": 5 }' ) ); | |
$bad = Maybe::of( json_decode( '{ "label": This is invalid JSON, "value": 5 }' ) ); | |
$good->map( function( $obj ) { echo $obj->value . "\n"; } ); | |
$bad->map( function( $obj ) { echo $obj->value . "\n"; } ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment