芝麻web文件管理V1.00
编辑当前文件:/home/qrafawbu/www/vendor/laravel/framework/src/Illuminate/Http/Client/ResponseSequence.php
responses = $responses; } /** * Push a response to the sequence. * * @param string|array $body * @param int $status * @param array $headers * @return $this */ public function push($body = '', int $status = 200, array $headers = []) { $body = is_array($body) ? json_encode($body) : $body; return $this->pushResponse( Factory::response($body, $status, $headers) ); } /** * Push a response with the given status code to the sequence. * * @param int $status * @param array $headers * @return $this */ public function pushStatus(int $status, array $headers = []) { return $this->pushResponse( Factory::response('', $status, $headers) ); } /** * Push response with the contents of a file as the body to the sequence. * * @param string $filePath * @param int $status * @param array $headers * @return $this */ public function pushFile(string $filePath, int $status = 200, array $headers = []) { $string = file_get_contents($filePath); return $this->pushResponse( Factory::response($string, $status, $headers) ); } /** * Push a response to the sequence. * * @param mixed $response * @return $this */ public function pushResponse($response) { $this->responses[] = $response; return $this; } /** * Make the sequence return a default response when it is empty. * * @param \GuzzleHttp\Promise\PromiseInterface|\Closure $response * @return $this */ public function whenEmpty($response) { $this->failWhenEmpty = false; $this->emptyResponse = $response; return $this; } /** * Make the sequence return a default response when it is empty. * * @return $this */ public function dontFailWhenEmpty() { return $this->whenEmpty(Factory::response()); } /** * Indicate that this sequence has depleted all of its responses. * * @return bool */ public function isEmpty() { return count($this->responses) === 0; } /** * Get the next response in the sequence. * * @return mixed */ public function __invoke() { if ($this->failWhenEmpty && count($this->responses) === 0) { throw new OutOfBoundsException('A request was made, but the response sequence is empty.'); } if (! $this->failWhenEmpty && count($this->responses) === 0) { return value($this->emptyResponse ?? Factory::response()); } return array_shift($this->responses); } }