{"action":"created","issue":{"url":"https://api.github.com/repos/schmittjoh/php-option/issues/22","labels_url":"https://api.github.com/repos/schmittjoh/php-option/issues/22/labels{/name}","comments_url":"https://api.github.com/repos/schmittjoh/php-option/issues/22/comments","events_url":"https://api.github.com/repos/schmittjoh/php-option/issues/22/events","html_url":"https://github.com/schmittjoh/php-option/issues/22","id":85892268,"number":22,"title":"then-like method to Option","user":{"login":"Strate","id":392644,"avatar_url":"https://avatars.githubusercontent.com/u/392644?v=3","gravatar_id":"","url":"https://api.github.com/users/Strate","html_url":"https://github.com/Strate","followers_url":"https://api.github.com/users/Strate/followers","following_url":"https://api.github.com/users/Strate/following{/other_user}","gists_url":"https://api.github.com/users/Strate/gists{/gist_id}","starred_url":"https://api.github.com/users/Strate/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Strate/subscriptions","organizations_url":"https://api.github.com/users/Strate/orgs","repos_url":"https://api.github.com/users/Strate/repos","events_url":"https://api.github.com/users/Strate/events{/privacy}","received_events_url":"https://api.github.com/users/Strate/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-07T11:16:02Z","updated_at":"2015-06-07T11:23:37Z","closed_at":null,"body":"JS Promise has a `then` method, which always returns a Promise, but handle callback's return value smartly: if it is already a Promise, `then`-created promise resolves to returned Promise value. I think that similar method helpful for PHP:\r\n\r\n```php\r\nOption::fromValue($value)\r\n  ->then(function($v1) { return $v1->get('123'); /* returns Option */ })\r\n  ->then(function($v2) { /*\r\n    $v2 here is value of $v1->get('123') Option, if it Some.\r\n    You can return value or Option from here\r\n  */ })\r\n```\r\n\r\nMethod name is discussable, but I think `then` is good enought, because it implement same behaviour as js pomise's `then` method."},"comment":{"url":"https://api.github.com/repos/schmittjoh/php-option/issues/comments/109739832","html_url":"https://github.com/schmittjoh/php-option/issues/22#issuecomment-109739832","issue_url":"https://api.github.com/repos/schmittjoh/php-option/issues/22","id":109739832,"user":{"login":"schmittjoh","id":197017,"avatar_url":"https://avatars.githubusercontent.com/u/197017?v=3","gravatar_id":"","url":"https://api.github.com/users/schmittjoh","html_url":"https://github.com/schmittjoh","followers_url":"https://api.github.com/users/schmittjoh/followers","following_url":"https://api.github.com/users/schmittjoh/following{/other_user}","gists_url":"https://api.github.com/users/schmittjoh/gists{/gist_id}","starred_url":"https://api.github.com/users/schmittjoh/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/schmittjoh/subscriptions","organizations_url":"https://api.github.com/users/schmittjoh/orgs","repos_url":"https://api.github.com/users/schmittjoh/repos","events_url":"https://api.github.com/users/schmittjoh/events{/privacy}","received_events_url":"https://api.github.com/users/schmittjoh/received_events","type":"User","site_admin":false},"created_at":"2015-06-07T11:23:37Z","updated_at":"2015-06-07T11:23:37Z","body":"Not so sure about that, we already have ``map`` and ``flatMap`` which you can use."}}