httpClient = $client; $this->config = $config; } public function getTrFlow() { /** @var Config $kanbanBoardUriParams */ $trFlowUri = $this->config->get('url.jcatTrFlow'); $response = $this->httpClient ->setUri($trFlowUri) ->send(); if (!$response->isSuccess()) { throw new \UnexpectedValueException("Bad JCAT result", $response->getStatusCode()); } return $this->parseFlowHtmlResult($response->getBody()); } private function parseFlowHtmlResult(string $html) { $xmlErrorHandling = libxml_use_internal_errors(TRUE); $domDocument = new \DOMDocument(); $domDocument->loadHTML($html); libxml_clear_errors(); libxml_use_internal_errors($xmlErrorHandling); $documentXpath = new \DOMXPath($domDocument); /** @var \DOMNodeList $elements */ $elements = $documentXpath->query('//tr/td[1]'); $result = []; /** @var \DOMElement $element */ foreach ($elements as $element) { $result[] = trim($element->nodeValue); } return array_count_values($result); } }