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