Example #1
0
 /**
  * @param $blueprint
  *
  * @return ApistFilter
  * @throws \InvalidArgumentException
  */
 public function each($blueprint = null)
 {
     $callback = $blueprint;
     if ($callback === null) {
         $callback = function ($node) {
             return $node;
         };
     }
     if (!is_callable($callback)) {
         $callback = function ($node) use($blueprint) {
             return $this->parser->parse($blueprint, $node);
         };
     }
     return $this->node->each($callback);
 }
Example #2
0
 /**
  * Perform method action
  *
  * @param array $arguments
  *
  * @return array
  * @throws \GuzzleHttp\Exception\GuzzleException
  *
  * @throws \InvalidArgumentException
  * @throws \RuntimeException
  */
 public function get(array $arguments = [])
 {
     try {
         $this->makeRequest($arguments);
     } catch (ConnectException $e) {
         $url = $e->getRequest()->getUri();
         return $this->errorResponse($e->getCode(), $e->getMessage(), $url);
     } catch (RequestException $e) {
         $url = $e->getRequest()->getUri();
         $status = $e->getCode();
         $response = $e->getResponse();
         $reason = $e->getMessage();
         if ($response !== null) {
             $reason = $response->getReasonPhrase();
         }
         return $this->errorResponse($status, $reason, $url);
     }
     $blueprintParser = new Blueprint($this->crawler);
     return $blueprintParser->parse($this->schemaBlueprint, $this->getCrawler());
 }