PHP code example of phpninjas / comprehensions

1. Go to this page and download the library: Download phpninjas/comprehensions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

phpninjas / comprehensions example snippets


$product = $entityManager->find('Product', "some identifier");

if ($product === null) {
    return $product->getName();   
}
return "";

$product = Option($entityManager->find('Product', "some identifier"));
$name = $product->map(function($p){
  return $p->getName();
});

return $name->getOrElse("");