@param Closure $closure

@return void

@throws DBALException
760702
public function inTransaction(Closure $closure): void
    {
        $connection = $this->getConnection();
        $connection->beginTransaction();
        try {
            $isOk = ($closure() === false ? null : true);
        } finally {
            isset($isOk) === true ? $connection->commit() : $connection->rollBack();
        }
    }
392590
public function extend($abstract, Closure $closure)
    {
        $abstract = $this->getAlias($abstract);

        if (isset($this->instances[$abstract])) {
            $this->instances[$abstract] = $closure($this->instances[$abstract], $this);

            $this->rebound($abstract);
        } else {
            $this->extenders[$abstract][] = $closure;

            if ($this->resolved($abstract)) {
                $this->rebound($abstract);
            }
        }
    }
410903
public function transaction(\Closure $closure, $connection = null)
  {
    if (!$this->inTransaction($connection)) {
      $this->beginTransaction($connection);
    }

    try {
      $result = $closure($this);
      $this->commit($connection);
    } catch (\Exception $e) {
      $this->rollback($connection);

      throw $e;
    }

    return $result;
  }
43968
public function apply(\Closure $function)
    {
        foreach ($this->model->countCaches() as $key => $cache) {
            $function($this->config($key, $cache));
        }
    }
538928
protected function transaction(Closure $callback)
    {
        db()->beginTransaction();
        try {
            $return = $callback();

            db()->commit();

            return $return;
        } catch (Exception $e) {
            db()->rollBack();

            return $this->exceptions($e);
        }
    }
749457
public function once(Closure $closure)
    {
        $hash = spl_object_hash((object) $closure);

        if ( ! isset ($this->called[$hash]))
        {
            $closure();

            $this->called[$hash] = true;
        }
    }
538314
public function reduce(\Closure $closure)
    {
        $nodes = [];
        foreach ($this->nodes as $i => $node) {
            if (false !== $closure($this->createSubCrawler($node), $i)) {
                $nodes[] = $node;
            }
        }

        return $this->createSubCrawler($nodes);
    }
1200517
public static function make($table, Closure $closure)
    {
        if (is_array($table)) {
            $table = isset($table['table']) ? $table['table'] : $table;
            $database = isset($table['database']) ? $table['database'] : null;
            $schema = new static($table, $database);
        } else {
            $schema = new static($table);
        }

        $callback = $closure($schema);
        /*
        | Set database connection name
        */
        $schema->on($schema->getDatabase());
        $schema->run();

        return $callback;
    }
601863
public function resolve($closure)
    {
        if (is_array($closure)) {
            $reflection = new \ReflectionMethod($closure[0], $closure[1]);
        } else {
            $reflection = new \ReflectionFunction($closure);
        }

        $arguments = $reflection->getParameters();

        $arguments = array_map(function ($argument) {
            return isset($this->bindMaps[$argument->name]) ? $this->bindMaps[$argument->name] : null;
        }, $arguments);

        return @call_user_func_array($closure, $arguments);
    }
357089
public function eachFillable(Closure $closure)
    {
        /** @var FillableField $item */
        foreach ($this->items as $item) {
            if ($item->fillable) {
                $closure($item);
            }
        }
    }
852403
public function orWhere(\Closure $closure = null) {
        $this->query->push(['OR']);
        if($closure !== null) $closure($this);

        return $this;
    }
1131745
public function group(Closure $closure): self
    {
        $expression = new Expression();
        $closure($expression);
        return $this->addExpression('group', $expression);
    }
764936
protected function setClosure(Shell $shell, \Closure $closure)
    {
        if (self::shouldBindClosure()) {
            $that = $shell->getBoundObject();
            if (\is_object($that)) {
                $closure = $closure->bindTo($that, \get_class($that));
            } else {
                $closure = $closure->bindTo(null, $shell->getBoundClass());
            }
        }

        $this->closure = $closure;
    }
220163
public function sort(Closure $closure)
    {
        $sorted = clone $this;

        $sorted->models = Objects::sort($sorted->models, $closure);

        return $sorted;
    }
460735
public function inTransaction(Closure $closure): void
    {
        $connection = $this->getConnection();
        $connection->beginTransaction();
        try {
            $isOk = ($closure() === false ? null : true);
        } finally {
            $isCommitting = (isset($isOk) === true);
            try {
                $isCommitting === true ? $connection->commit() : $connection->rollBack();
            } /** @noinspection PhpRedundantCatchClauseInspection */ catch (ConEx | DBALException $exception) {
                throw new RepositoryException(
                    $isCommitting === true ? 'Failed to commit a transaction.' : 'Failed to rollback a transaction.',
                    0,
                    $exception
                );
            }
        }
    }
647163
public function getFilterCallback(Closure $closure)
  {
    $filter = function(&$item) use ($closure){
      $closure($item);
      return true;
    };
    return $filter;
  }
96594
public function requireWhen(\Closure $closure) {
        $need = $closure();
        $this->check_role = 'require';
        $result = true;
        if ($need) {
            $result = !empty($this->value) || '0' == $this->value;
        }
        $this->checkResult($result);
    }