예제 #1
0
 /**
  * If you pass in `true`, you get back a SearchInfo object related to the
  * last call. Keep in mind that passing in true before calling a default
  * call() will implicitly call the call(), and then get the SearchInfo.
  *
  * So:
  *
  * $searchApi->call() // gets entities
  * $searchApi->call(true) // gets SearchInfo about the executed query
  *
  * @todo: remove error avoidance when issue 12 is fixed: https://github.com/Swader/diffbot-php-client/issues/12
  * @param bool $info
  * @return \Swader\Diffbot\Entity\EntityIterator|SearchInfo
  */
 public function call($info = false)
 {
     if (!$info) {
         $ei = parent::call();
         set_error_handler(function () {
             /* ignore errors */
         });
         $arr = $ei->getResponse()->json(['big_int_strings' => true]);
         restore_error_handler();
         unset($arr['request']);
         unset($arr['objects']);
         $this->info = new SearchInfo($arr);
         return $ei;
     }
     if ($info && !$this->info) {
         $this->call();
     }
     return $this->info;
 }
예제 #2
0
 /**
  * If you pass in `true`, you get back a SearchInfo object related to the
  * last call. Keep in mind that passing in true before calling a default
  * call() will implicitly call the call(), and then get the SearchInfo.
  *
  * So:
  *
  * $searchApi->call() // gets entities
  * $searchApi->call(true) // gets SearchInfo about the executed query
  *
  * @todo: remove error avoidance when issue 12 is fixed: https://github.com/Swader/diffbot-php-client/issues/12
  * @param bool $info
  * @return EntityIterator|SearchInfo
  */
 public function call($info = false)
 {
     if (!$info) {
         $ei = parent::call();
         set_error_handler(function () {
             /* ignore errors */
         });
         $arr = json_decode((string) $ei->getResponse()->getBody(), true, 512, 1);
         restore_error_handler();
         unset($arr['request']);
         unset($arr['objects']);
         $this->info = new SearchInfo($arr);
         return $ei;
     }
     if ($info && !$this->info) {
         $this->call();
     }
     return $this->info;
 }