url = $url; $this->testString = $testString; } /** * {@inheritDoc} * * @return array * @throws HTTPResponse_Exception */ public function check() { $response = Director::test($this->url); if ($response->getStatusCode() != 200) { return [ EnvironmentCheck::ERROR, sprintf('Error retrieving "%s" (Code: %d)', $this->url, $response->getStatusCode()) ]; } elseif ($this->testString && (strpos($response->getBody(), $this->testString) === false)) { return [ EnvironmentCheck::WARNING, sprintf('Success retrieving "%s", but string "%s" not found', $this->url, $this->testString) ]; } return [ EnvironmentCheck::OK, sprintf('Success retrieving "%s"', $this->url) ]; } }