Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
dfridrich committed Dec 13, 2016
1 parent 84fe0ed commit abba190
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 17 deletions.
36 changes: 19 additions & 17 deletions src/Ares.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class Ares
*/
private $contextOptions = [
'ssl' => [
'verify_peer' => false,
'verify_peer' => false,
'verify_peer_name' => false,
],
];
Expand All @@ -69,7 +69,7 @@ public function __construct($cacheDir = null, $debug = false, $balancer = null)
$this->balancer = $balancer;
}

$this->cacheDir = $cacheDir . '/defr/ares';
$this->cacheDir = $cacheDir.'/defr/ares';
$this->debug = $debug;

// Create cache dirs if they doesn't exist
Expand All @@ -80,6 +80,7 @@ public function __construct($cacheDir = null, $debug = false, $balancer = null)

/**
* @param $balancer
*
* @return $this
*/
public function setBalancer($balancer)
Expand All @@ -91,12 +92,13 @@ public function setBalancer($balancer)

/**
* @param $url
*
* @return mixed
*/
private function wrapUrl($url)
{
if ($this->balancer) {
$url = sprintf("%s?url=%s", $this->balancer, urlencode($url));
$url = sprintf('%s?url=%s', $this->balancer, urlencode($url));
}

$this->lastUrl = $url;
Expand Down Expand Up @@ -125,9 +127,9 @@ public function findByIdentificationNumber($id)
$id = Lib::toInteger($id);
$this->ensureIdIsInteger($id);

$cachedFileName = $id . '_' . date($this->cacheStrategy) . '.php';
$cachedFile = $this->cacheDir . '/bas_' . $cachedFileName;
$cachedRawFile = $this->cacheDir . '/bas_raw_' . $cachedFileName;
$cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
$cachedFile = $this->cacheDir.'/bas_'.$cachedFileName;
$cachedRawFile = $this->cacheDir.'/bas_raw_'.$cachedFileName;

if (is_file($cachedFile)) {
return unserialize(file_get_contents($cachedFile));
Expand All @@ -148,7 +150,7 @@ public function findByIdentificationNumber($id)
$data = $aresResponse->children($ns['are']);
$elements = $data->children($ns['D'])->VBAS;

$ico = (int)$elements->ICO;
$ico = (int) $elements->ICO;
if ($ico !== $id) {
throw new AresException('IČ firmy nebylo nalezeno.');
}
Expand All @@ -168,7 +170,7 @@ public function findByIdentificationNumber($id)
}

if (strval($elements->AA->NCO)) {
$record->setTown(strval($elements->AA->N . ' - ' . strval($elements->AA->NCO)));
$record->setTown(strval($elements->AA->N.' - '.strval($elements->AA->NCO)));
} else {
$record->setTown(strval($elements->AA->N));
}
Expand Down Expand Up @@ -202,9 +204,9 @@ public function findInResById($id)
// Sestaveni URL
$url = $this->wrapUrl(sprintf(self::URL_RES, $id));

$cachedFileName = $id . '_' . date($this->cacheStrategy) . '.php';
$cachedFile = $this->cacheDir . '/res_' . $cachedFileName;
$cachedRawFile = $this->cacheDir . '/res_raw_' . $cachedFileName;
$cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
$cachedFile = $this->cacheDir.'/res_'.$cachedFileName;
$cachedRawFile = $this->cacheDir.'/res_raw_'.$cachedFileName;

if (is_file($cachedFile)) {
return unserialize(file_get_contents($cachedFile));
Expand Down Expand Up @@ -263,9 +265,9 @@ public function findVatById($id)
// Sestaveni URL
$url = $this->wrapUrl(sprintf(self::URL_TAX, $id));

$cachedFileName = $id . '_' . date($this->cacheStrategy) . '.php';
$cachedFile = $this->cacheDir . '/tax_' . $cachedFileName;
$cachedRawFile = $this->cacheDir . '/tax_raw_' . $cachedFileName;
$cachedFileName = $id.'_'.date($this->cacheStrategy).'.php';
$cachedFile = $this->cacheDir.'/tax_'.$cachedFileName;
$cachedRawFile = $this->cacheDir.'/tax_raw_'.$cachedFileName;

if (is_file($cachedFile)) {
return unserialize(file_get_contents($cachedFile));
Expand Down Expand Up @@ -321,9 +323,9 @@ public function findByName($name, $city = null)
urlencode(Lib::stripDiacritics($city))
));

$cachedFileName = date($this->cacheStrategy) . '_' . md5($name . $city) . '.php';
$cachedFile = $this->cacheDir . '/find_' . $cachedFileName;
$cachedRawFile = $this->cacheDir . '/find_raw_' . $cachedFileName;
$cachedFileName = date($this->cacheStrategy).'_'.md5($name.$city).'.php';
$cachedFile = $this->cacheDir.'/find_'.$cachedFileName;
$cachedRawFile = $this->cacheDir.'/find_raw_'.$cachedFileName;

if (is_file($cachedFile)) {
return unserialize(file_get_contents($cachedFile));
Expand Down
2 changes: 2 additions & 0 deletions src/Ares/AresRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ class AresRecord

/**
* AresRecord constructor.
*
* @param int $companyId
* @param string $taxId
* @param string $companyName
Expand Down Expand Up @@ -169,6 +170,7 @@ public function getZip()

/**
* @param GouteClient $client
*
* @return $this
*/
public function setClient(GouteClient $client)
Expand Down
1 change: 1 addition & 0 deletions src/Ares/TaxRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class TaxRecord

/**
* TaxRecord constructor.
*
* @param string $taxId
*/
public function __construct($taxId)
Expand Down
1 change: 1 addition & 0 deletions src/Justice.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ public function findById($id)

/**
* @param Crawler $crawler
*
* @return false|int
*/
private function extractDetailUrlFromCrawler(Crawler $crawler)
Expand Down
1 change: 1 addition & 0 deletions src/Parser/JusticeJednatelPersonParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final class JusticeJednatelPersonParser
{
/**
* @param Crawler $crawler
*
* @return Person
*/
public static function parseFromDomCrawler(Crawler $crawler)
Expand Down
1 change: 1 addition & 0 deletions src/Parser/JusticeSpolecnikPersonParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ final class JusticeSpolecnikPersonParser
{
/**
* @param Crawler $crawler
*
* @return Person
*/
public static function parseFromDomCrawler(Crawler $crawler)
Expand Down

0 comments on commit abba190

Please sign in to comment.