@param array|Countable $flow

@return $this
435404
public function setTotalFrom($flow): ProgressBuilder
    {
        if (is_array($flow) || (is_object($flow) && $flow instanceof Countable)) { // is_countable() from PHP 7.3+
            $this->total = count($flow);
        } else {
            throw new \InvalidArgumentException('Array or \\Countable object');
        }

        return $this;
    }
534635
public function setContext($var)
    {
        GPBUtil::checkMessage($var, \Google\Cloud\Dialogflow\V2\Context::class);
        $this->context = $var;

        return $this;
    }
420
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $subject = $arguments[0];
        if (!isset($subject) || empty($subject)) {
            $flowQuery->setContext([]);
            return;
        }

        $filteredContext = [];
        $context = $flowQuery->getContext();
        if (is_string($subject)) {
            foreach ($context as $contextElement) {
                $contextElementQuery = new FlowQuery([$contextElement]);
                $contextElementQuery->pushOperation('children', $arguments);
                if ($contextElementQuery->count() > 0) {
                    $filteredContext[] = $contextElement;
                }
            }
        } else {
            if ($subject instanceof FlowQuery) {
                $elements = $subject->get();
            } elseif ($subject instanceof \Traversable) {
                $elements = iterator_to_array($subject);
            } elseif (is_object($subject)) {
                $elements = [$subject];
            } elseif (is_array($subject)) {
                $elements = $subject;
            } else {
                throw new FizzleException('supplied argument for has operation not supported', 1332489625);
            }
            foreach ($elements as $element) {
                if ($element instanceof TraversableNodeInterface) {
                    $parentsQuery = new FlowQuery([$element]);
                    foreach ($parentsQuery->parents([])->get() as $parent) {
                        /** @var TraversableNodeInterface $parent */
                        foreach ($context as $contextElement) {
                            /** @var TraversableNodeInterface $contextElement */
                            if ($contextElement === $parent) {
                                $filteredContext[] = $contextElement;
                            }
                        }
                    }
                }
            }
            $filteredContext = array_unique($filteredContext);
        }

        $flowQuery->setContext($filteredContext);
    }
1334634
public function evaluate(FlowQuery $flowQuery, array $arguments)
    {
        $context = $flowQuery->getContext();
        if ($context instanceof \Iterator) {
            $context = iterator_to_array($context);
        }
        if (isset($arguments[0]) && isset($arguments[1])) {
            $context = array_slice($context, (integer)$arguments[0], (integer)$arguments[1] - (integer)$arguments[0]);
        } elseif (isset($arguments[0])) {
            $context = array_slice($context, (integer)$arguments[0]);
        }

        $flowQuery->setContext($context);
    }
624194
public function decrementPosition($count = 1)
    {
        if ($this->isNotInList()) return $this;

        $newPosition = $this->getListifyPosition() - $count;

        if ($newPosition < $this->listifyTop()) {
            $newPosition = $this->listifyTop();
        }

        $this->setListifyPosition($newPosition);

        return $this;
    }
973965
public function setAmount(MoneyInterface $amount): self
    {
        if (null === $this->amount) {
            $this->amount = $amount;
        }

        return $this;
    }
1246960
public function flowEnd()
    {
        $this->flowStats['end']     = microtime(true);
        $this->flowStats['mib']     = memory_get_peak_usage(true) / 1048576;
        $this->flowStats['elapsed'] = $this->flowStats['end'] - $this->flowStats['start'];

        $this->flowStats = array_replace($this->flowStats, $this->duration($this->flowStats['elapsed']));

        return $this;
    }
623663
public function setStream(string $stream): self
    {
        $this->stream = $stream;
        $this->createByteCache();
        return $this;
    }
10569
public function down ( $count = 0 ) {
        $this->_currentPosition = array(
                                        $this->_currentPosition[0],
                                        $this->_currentPosition[1] + $count,
                                       );
        return $this;
    }
136003
public function count($count, $error) {
        if ($this->_exist) {
            array_push($this->_constraints, ['type' => self::COUNT, 'value' => $count, 'message' => $error]);
        }

        return $this;
    }
935621
public function limit(int $amount)
    {
        $this->items = array_slice($this->items, 0, $amount);

        return $this;
    }
893282
public function setAmount($value)
    {
        if (empty($value)) {
            $this->currentObject->setAmount(null);
        } elseif ($value instanceof AmountInterface) {
            if ($value->getValue() > 0.0) {
                $this->currentObject->setAmount($value->getValue());
            }
            $this->currentObject->setCurrency($value->getCurrency());
        } else {
            $this->currentObject->setAmount($value);
        }
        return $this;
    }
1045805
protected function flowEnd()
    {
        $this->flowMap->flowEnd();
        $eventName = FlowEvent::FLOW_SUCCESS;
        $node      = null;
        if ($this->flowStatus->isException()) {
            $eventName = FlowEvent::FLOW_FAIL;
            $node      = $this->nodes[$this->nodeIdx];
        }

        // restore nodeIdx
        $this->nodeIdx = $this->lastIdx + 1;
        $this->triggerEvent($eventName, $node);

        return $this;
    }
396273
public function map(callable $func)
    {
        // That's the standard case for any next stages
        if (\is_iterable($this->pipeline)) {
            $this->pipeline = self::apply($this->pipeline, $func);

            return $this;
        }

        // Let's check what we got for a start
        $this->pipeline = $func();

        // Generator is a generator, moving along
        if ($this->pipeline instanceof \Generator) {
            return $this;
        }

        // Not a generator means we were given a simple value to be treated as an array
        // We do not cast to an array here because casting a null to an array results in
        // an empty array; that's surprising and not how map() works for other values
        $this->pipeline = [
            $this->pipeline,
        ];

        return $this;
    }
1221546
public function setAmount(float $amount): self
    {
        $this->amount = (int) ($amount * self::FACTOR_AMOUNT);
        return $this;
    }
396985
public function setCollection($collection)
    {
        $this->collection = (array) $collection;
        $this->setCount(count($this->collection));

        return $this;
    }
529308
public function setStream($stream)
    {
        if (! is_resource($stream) || ! 'stream' == get_resource_type($stream)) {
            throw new \InvalidArgumentException(sprintf(
                'Expects argument to be a stream resource, got %s',
                is_resource($stream) ? get_resource_type($stream) : gettype($stream)
            ));
        }

        $this->stream = $stream;

        return $this;
    }