Exemplo n.º 1
0
 /**
  * @param array $data
  * @return Option
  */
 public function extract($data)
 {
     $secondExtractor = $this->secondExtractor;
     return $this->firstExtractor->extract($data)->apply(function ($firstResult) use($secondExtractor) {
         return $secondExtractor->extract($firstResult);
     });
 }
Exemplo n.º 2
0
 /**
  * @param array $data
  * @return Option
  */
 public function extract($data)
 {
     $result = array();
     foreach ($data as $row) {
         $r = $this->innerExtractor->extract($row)->getOrElse(null);
         if ($r !== null) {
             $result[] = $r;
         }
     }
     return $result ? new Some($this->process($result)) : None::create();
 }
Exemplo n.º 3
0
 /**
  * @param Extractor $extractor
  * @param string $expected
  */
 private function assertExtracts($extractor, $expected)
 {
     $this->assertEquals($expected, $extractor->extract($this->sample)->getOrElse(null));
 }
Exemplo n.º 4
0
 /**
  * @param Extractor $extractor
  * @param string $expected
  */
 private function assertExtracts($extractor, $expected)
 {
     $sample = array('foo' => array('bar' => 'result'), 'baz' => 'something');
     $this->assertEquals($expected, $extractor->extract($sample)->getOrElse(null));
 }