示例#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);
     });
 }
示例#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();
 }
示例#3
0
 /**
  * @param Extractor $extractor
  * @param string $expected
  */
 private function assertExtracts($extractor, $expected)
 {
     $this->assertEquals($expected, $extractor->extract($this->sample)->getOrElse(null));
 }
示例#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));
 }