Amp\Artax\FormBody::getLength PHP Method

getLength() public method

AggregateBody::getLength() implementations always return a Promise instance to allow for future resolution of non-blocking operations (e.g. when using filesystem stats to determine entity body length).
public getLength ( ) : Amp\Promise
return Amp\Promise
    public function getLength()
    {
        if (isset($this->cachedLength)) {
            return new Success($this->cachedLength);
        } elseif ($this->isMultipart) {
            $fields = $this->getMultipartFieldArray();
            $length = $this->sumMultipartFieldLengths($fields);
            $length->when(function ($error, $result) {
                if (empty($error)) {
                    $this->cachedLength = $result;
                }
            });
            return $length;
        } else {
            $length = strlen($this->getFormEncodedBodyString());
            return new Success($length);
        }
    }