Retrieve a cloned copy of the specified builder.
@param string|Builder $builder
@param string         $type The new type of the cloned builder.
@return Builder
347459
public function copy($builder, $type = null)
    {
        if (!($builder instanceof Builder)) {
            $builder = $this->retrieve($builder);
        }
        return $builder->copy($type);
    }
524348
private function applyOrdering($builder)
    {
        foreach ($this->ordering as $column => $order) {
            $builder->orderBy($column, $order);
        }

        return $builder;
    }
808218
public function extend(Builder $builder)
    {
        foreach ($this->extensions as $extension) {
            $this->{"add{$extension}"}($builder);
        }

        $builder->onDelete(function(Builder $builder)
        {
            $column = $this->getDeletedAtColumn($builder);

            return $builder->update(array(
                $column => $builder->getModel()->freshTimestampString()
            ));
        });
    }
410753
public function createFromBuilder(Builder $builder)
    {
        $this->model = $builder->getModel();
        $this->query = $builder;

        $this->build();

        return $this;
    }
655977
protected function addVersion(Builder $builder)
    {
        $builder->macro('version', function(Builder $builder, $version) {
            $model = $builder->getModel();

            $this->remove($builder, $builder->getModel());

            $builder->join($model->getVersionTable(), function($join) use ($model, $version) {
                $join->on($model->getQualifiedKeyName(), '=', $model->getQualifiedVersionKeyName());
                $join->where($model->getQualifiedVersionColumn(), '=', $version);
            });

            return $builder;
        });
    }
499820
protected function addPending(Builder $builder)
    {
        $builder->macro('pending', function (Builder $builder) {
            $model = $builder->getModel();

            $this->remove($builder, $model);

            $builder->where($model->getQualifiedStatusColumn(), '=', Status::PENDING);

            return $builder;
        });
    }
301156
public function createBuilder($type, array $options = [])
    {
        $metaType = $this->createType($type);
        $options = $this->getOptions($metaType, $options);

        $dataClass = isset($options['data_class']) ? $options['data_class'] : Meta::class;
        $builder = new MetaBuilder($this, $dataClass);
        $this->buildMeta($builder, $metaType, $options);

        return $builder;
    }
93446
public function get(Builder $builder)
    {
        // First, we will retrieve the field's value using our composed behavior.
        $value = $this->behavior->get(
            $builder->field,
            $builder->id,
            ! $builder->raw
        );

        // Next, we will iterate over the defined components and pass our value
        // through each component's method if it was defined on the builder.
        foreach ($this->components as $component) {
            if (! is_null($builder->$component)) {
                $method = 'run'.ucfirst($component);

                $value = $this->$method($builder->$component, $value);
            }
        }

        return $value;
    }
117656
private static function getBuilder($name, $type)
    {
        static $builders = [];
        if (isset($builders[$type][$name])) {
            return $builders[$type][$name];
        }

        $builderClassMap = self::$builderClassMap[$type];

        if (isset($builderClassMap[$name])) {
            return $builders[$type][$name] = new $builderClassMap[$name]();
        }
        // deprecated relay builder name ?
        $newName = 'Relay::'.\rtrim($name, 'Args');
        if (isset($builderClassMap[$newName])) {
            @\trigger_error(
                \sprintf('The "%s" %s builder is deprecated as of 0.7 and will be removed in 0.12. Use "%s" instead.', $name, $type, $newName),
                \E_USER_DEPRECATED
            );

            return $builders[$type][$newName] = new $builderClassMap[$newName]();
        }

        throw new InvalidConfigurationException(\sprintf('%s builder "%s" not found.', \ucfirst($type), $name));
    }
941700
public static function getInstance($type, $data = null)
    {
        $classname = self::classname($type);

        if (!isset(self::$__instances[$classname])) {
            $instance = new $classname();
            self::$__instances[$classname] = $instance;
        }

        $instance = clone self::$__instances[$classname];

        if ($data) {
            $instance->unserialize($data);
        }

        return $instance;
    }
607542
public function serialyse(QueryBuilderInterface $Builder) {
        $this->parsedQuery = $this->getSerialyser()->setCriteriaList($Builder)->serialyse();
        return $this;
    }
575038
public static <K extends Comparable<?>, V> Builder<K, V> builder() {
    return new Builder<K, V>();
  }
471134
public function scopeOfCreator(Builder $builder, Model $user): Builder
    {
        return $builder->where('created_by_type', $user->getMorphClass())->where('created_by_id', $user->getKey());
    }
929318
public Datatype.Builder setBuilder(Type builder) {
    this.builder = Objects.requireNonNull(builder);
    _unsetProperties.remove(Property.BUILDER);
    return (Datatype.Builder) this;
  }
1213202
protected function cloneByHttp(Builder $builder, $cloneTo)
    {
        return $builder->executeCommand('hg clone %s "%s" -r %s', $this->getCloneUrl(), $cloneTo, $this->getBranch());
    }
569456
protected function addKeep(Builder $builder): void
    {
        $builder->macro('keep', function (Builder $builder) {
            $builder->withNotKept();

            return $builder->update(['is_kept' => 1]);
        });
    }
1183338
public function getConfiguredBuilder(Table $table, $type)
    {
        $class = $this->builders[$type];
        require_once dirname(__FILE__) . '/../builder/om/' . $class . '.php';
        $builder = new $class($table);
        $builder->setGeneratorConfig($this);

        return $builder;
    }