Beispiel #1
0
 /**
  * Load XML and fill Data object
  * @param string|int $inn
  * @param bool $includeExpired
  * @return Data
  * @throws IdentificationNumberNotFoundException
  */
 private function loadXML($inn, $includeExpired = FALSE)
 {
     $this->clean();
     // Subject identification numbers are by definition exactly 8 digits long
     // Older INs are padded from left with zeroes
     $IN = intval($inn);
     $IN = str_pad((string) $IN, 8, '0', STR_PAD_LEFT);
     $url = $this->buildUrl($IN, $includeExpired);
     $xmlSource = CUrl\CurlBuilder::download($url);
     $xml = @simplexml_load_string($xmlSource);
     if (!$xml) {
         throw new IdentificationNumberNotFoundException();
     }
     $ns = $xml->getDocNamespaces();
     $xmlEl = $xml->children($ns['are'])->children($ns['D'])->VBAS;
     // When IN is not found, ARES returns 200 OK and error description in D:E tag
     // So this is a simplified detection, if no D:VBAS->ICO is present, consider the request invalid
     if (!isset($xmlEl->ICO)) {
         throw new IdentificationNumberNotFoundException();
     }
     $street = strval($xmlEl->AD->UC);
     if (is_numeric($street)) {
         $street = $xmlEl->AA->NCO . ' ' . $street;
     }
     if (isset($xmlEl->AA->CO)) {
         $street .= '/' . $xmlEl->AA->CO;
     }
     $this->data->setIN($xmlEl->ICO)->setVatIN($xmlEl->DIC)->setCity($xmlEl->AA->N)->setCompany($xmlEl->OF)->setStreet($street)->setZip($xmlEl->AA->PSC)->setPerson($xmlEl->PF->KPF)->setCreated($xmlEl->DV);
     if (isset($xmlEl->ROR)) {
         $this->data->setActive($xmlEl->ROR->SOR->SSU)->setFileNumber($xmlEl->ROR->SZ->OV)->setCourt($xmlEl->ROR->SZ->SD->T);
     }
     return $this->data;
 }
Beispiel #2
0
 public function testCurlMulti()
 {
     $a = CurlBuilder::createDownload(self::TEST_URL_95);
     $b = CUrlBuilder::createDownload(self::TEST_URL_96);
     $multi = new CurlMulti();
     $multi->addHandles(array('1995-12-30' => $a), $b);
     $multi->exec();
     $this->assertEquals(file_get_contents(__DIR__ . '/testCurlMulti.txt'), serialize($multi->getSelect()));
 }
Beispiel #3
0
 /**
  * Na datum posledního neúspěšně staženého dne
  *
  * @param mixed $date
  * @return string
  */
 public function setLastDate($date)
 {
     $this->requestUrl = self::REST_URL . sprintf('set-last-date/%s/%s/', $this->token, DateTime::from($date)->format('Y-m-d'));
     $this->availableAnotherRequest();
     return CurlBuilder::download($this->requestUrl);
 }