* tsp-info endpoint added

* different collector services are now implemented
This commit is contained in:
Dávid Danyi
2017-09-05 19:15:17 +02:00
parent 88527e4ff1
commit efc6e7b0c4
16 changed files with 855 additions and 63 deletions

View File

@@ -0,0 +1,70 @@
<?php
namespace App\Service;
use League\Csv\Reader;
use League\Csv\Statement;
use Zend\Config\Config;
use Zend\Http\Client;
class JcatInfoCollectorService
{
/**
* @var Config
*/
private $config;
/**
* @var Client
*/
private $httpClient;
/**
* JiraClientService constructor.
* @param Client $client
* @param Config $config
*/
public function __construct(Client $client, Config $config)
{
$this->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);
}
}