reset(); } /** * Matches request by hostname. * * @param string $host * * @return $this */ public function host(string $host): PockBuilder { $this->closePrevious(); $this->matcher->addMatcher(new HostMatcher($host)); return $this; } /** * Resets the builder. * * @return \Pock\PockBuilder */ public function reset(): PockBuilder { $this->matcher = new MultipleMatcher(); $this->response = null; $this->throwable = null; $this->mocks = []; } public function getClient(): Client { return new Client($this->mocks); } private function closePrevious(): void { if (null !== $this->response || null !== $this->throwable) { if (0 === count($this->matcher)) { $this->matcher->addMatcher(new AnyRequestMatcher()); } $this->mocks[] = new Mock($this->matcher, $this->response, $this->throwable); $this->response = null; $this->throwable = null; } } }