/**
  * @param string $type
  * @param \Closure $generateImage
  * @param \Closure $checkOutput
  * @param array $logLevels
  * @dataProvider imageProvider
  */
 public function testCorrect(string $type, \Closure $generateImage, \Closure $checkOutput, array $logLevels = [])
 {
     $validator = new ImageValidator($type, '');
     $validator->setLogger($this);
     $checkOutput->call($this, $validator->correct($generateImage()));
     $this->assertEquals($logLevels, $this->logLevels);
 }
Example #2
0
 /**
  * @param string $name
  * @param array $Args
  * @return Client|string
  * @throws \Exception
  */
 public function __call($name, array $Args = [])
 {
     if (is_null($this->namespace)) {
         $this->namespace = Src::frcm($name, '-');
         return $this;
     }
     try {
         $Bridge = (new Bridge($this->url, Bridge::RM_POST))->withToken($this->token)->withMethod($name)->withNamespace($this->namespace)->withParams($Args);
         if (count($this->Watchers) > 0) {
             foreach ($this->Watchers as $Watcher) {
                 $Bridge->with($Watcher->getKey(), $Watcher->watch());
             }
         }
         return !is_null($this->Wrapper) ? $this->Wrapper->call($this, $Bridge->send()) : $Bridge->send();
     } finally {
         $this->namespace = null;
     }
 }
Example #3
0
 /**
  * Send immediately
  */
 public function renderJson()
 {
     $totalCount = $this->getDatasource()->totalCount();
     $rows = $this->getDatasource()->listRows();
     $tmpData = [];
     foreach ($rows as $row) {
         $tmp = [];
         $this->currentRow = new DefaultRow();
         if ($this->rowCallback instanceof \Closure) {
             $this->rowCallback->call($this, $row);
         }
         foreach ($this->getColumns() as $key => $column) {
             $this->currentColumn = $key;
             $tmp[$column->getName()] = $column->format($row);
         }
         $tmpData[] = $tmp;
     }
     $data = ['draw' => $this->getRequest()->get('draw'), 'recordsTotal' => $totalCount, 'recordsFiltered' => $totalCount, 'data' => $tmpData];
     header('Content-Type: application/json');
     echo json_encode($data);
     die;
 }
Example #4
0
 public function execute(\Closure $closure)
 {
     return $closure->call($this->restrictedEnvironment);
 }
 /**
  * @param \Closure $closure
  *
  * @return TransformInterface
  */
 protected final function invokeClosure(\Closure $closure) : TransformInterface
 {
     $bindTo = $this->isMutable() ? $this : clone $this;
     $result = $closure->call($bindTo, $bindTo);
     return $this->readyResult($result);
 }
Example #6
0
 /**
  * @param array $path
  * @return array
  */
 public function handle(array $path) : array
 {
     return $this->closure->call($this, $path);
 }
Example #7
0
 public function __construct(string $dir, string $sourceDir, string $routePath = null, \Closure $fn = null)
 {
     $this->docDir = $dir;
     $this->source = $sourceDir;
     if (!is_dir($sourceDir)) {
         throw new \Error("Source directory does not exist, or it is not a directory!");
     }
     if (!empty($routePath)) {
         $this->setRoutePath($routePath);
     }
     if (isset($fn)) {
         $fn->call($this);
     }
 }