Skip to content

Commit

Permalink
typos
Browse files Browse the repository at this point in the history
  • Loading branch information
petrparolek committed Sep 28, 2021
1 parent f927c0c commit e5b821d
Show file tree
Hide file tree
Showing 16 changed files with 72 additions and 53 deletions.
2 changes: 1 addition & 1 deletion examples/ares.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

require __DIR__.'/../vendor/autoload.php';
require __DIR__ . '/../vendor/autoload.php';

use Defr\Ares;

Expand Down
54 changes: 29 additions & 25 deletions src/Ares.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
*/
class Ares
{

const URL_BAS = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_bas.cgi?ico=%s';

const URL_RES = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/darv_res.cgi?ICO=%s';

const URL_TAX = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/ares_es.cgi?ico=%s&filtr=0';

const URL_FIND = 'http://wwwinfo.mfcr.cz/cgi-bin/ares/ares_es.cgi?obch_jm=%s&obec=%s&filtr=0';

/**
Expand Down Expand Up @@ -70,7 +74,7 @@ public function __construct($cacheDir = null, $debug = false, $balancer = null)
$this->balancer = $balancer;
}

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

// Create cache dirs if they doesn't exist
Expand Down Expand Up @@ -118,10 +122,10 @@ public function getLastUrl()
/**
* @param $id
*
* @throws InvalidArgumentException
* @return AresRecord
* @throws Ares\AresException
*
* @return AresRecord
* @throws InvalidArgumentException
*/
public function findByIdentificationNumber($id)
{
Expand All @@ -132,9 +136,9 @@ public function findByIdentificationNumber($id)
throw new AresException('IČ firmy musí být zadáno.');
}

$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 @@ -144,7 +148,7 @@ public function findByIdentificationNumber($id)
$url = $this->wrapUrl(sprintf(self::URL_BAS, $id));

try {
$aresRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
$aresRequest = file_get_contents($url, null, stream_context_create($this->contextOptions));
if ($this->debug) {
file_put_contents($cachedRawFile, $aresRequest);
}
Expand Down Expand Up @@ -175,9 +179,9 @@ public function findByIdentificationNumber($id)
}

if (strval($elements->AA->N) === 'Praha') { //Praha
$record->setTown(strval($elements->AA->NMC).' - '.strval($elements->AA->NCO));
$record->setTown(strval($elements->AA->NMC) . ' - ' . strval($elements->AA->NCO));
} elseif (strval($elements->AA->NCO) !== strval($elements->AA->N)) { //Ostrava
$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 All @@ -187,7 +191,7 @@ public function findByIdentificationNumber($id)
throw new AresException('Databáze ARES není dostupná.');
}
} catch (\Exception $e) {
throw new AresException($e->getMessage());
throw new AresException($e->getMessage());
}

file_put_contents($cachedFile, serialize($record));
Expand All @@ -198,10 +202,10 @@ public function findByIdentificationNumber($id)
/**
* @param $id
*
* @throws InvalidArgumentException
* @return AresRecord
* @throws Ares\AresException
*
* @return AresRecord
* @throws InvalidArgumentException
*/
public function findInResById($id)
{
Expand All @@ -211,9 +215,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 @@ -258,10 +262,10 @@ public function findInResById($id)
/**
* @param $id
*
* @throws InvalidArgumentException
* @return string
* @throws \Exception
*
* @return string
* @throws InvalidArgumentException
*/
public function findVatById($id)
{
Expand All @@ -272,9 +276,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 @@ -313,10 +317,10 @@ public function findVatById($id)
* @param string $name
* @param null $city
*
* @throws InvalidArgumentException
* @return array|AresRecord[]|AresRecords
* @throws AresException
*
* @return array|AresRecord[]|AresRecords
* @throws InvalidArgumentException
*/
public function findByName($name, $city = null)
{
Expand All @@ -330,9 +334,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
1 change: 1 addition & 0 deletions src/Ares/AresException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
*/
class AresException extends \Exception
{

}
10 changes: 6 additions & 4 deletions src/Ares/AresRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
class AresRecord
{

/**
* @var int
*/
Expand Down Expand Up @@ -80,7 +81,8 @@ public function __construct(
$streetOrientationNumber = null,
$town = null,
$zip = null
) {
)
{
$this->companyId = $companyId;
$this->taxId = !empty($taxId) ? $taxId : null;
$this->companyName = $companyName;
Expand All @@ -96,10 +98,10 @@ public function __construct(
*/
public function getStreetWithNumbers()
{
return $this->street.' '
.($this->streetOrientationNumber
return $this->street . ' '
. ($this->streetOrientationNumber
?
$this->streetHouseNumber.'/'.$this->streetOrientationNumber
$this->streetHouseNumber . '/' . $this->streetOrientationNumber
:
$this->streetHouseNumber);
}
Expand Down
3 changes: 2 additions & 1 deletion src/Ares/AresRecords.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
*/
final class AresRecords implements \ArrayAccess, \IteratorAggregate, \Countable
{

/**
* @var AresRecord[]
*/
Expand Down Expand Up @@ -45,7 +46,7 @@ public function offsetGet($offset)
}

/**
* @param mixed $offset
* @param mixed $offset
* @param AresRecord $value
*/
public function offsetSet($offset, $value)
Expand Down
1 change: 1 addition & 0 deletions src/Ares/TaxRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
*/
class TaxRecord
{

/**
* @var string
*/
Expand Down
5 changes: 3 additions & 2 deletions src/Justice.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

final class Justice
{

/**
* @var string
*/
Expand Down Expand Up @@ -40,9 +41,9 @@ public function __construct(Client $client)
/**
* @param string $id
*
* @return JusticeRecord|false
* @throws SubjectNotFoundException
*
* @return JusticeRecord|false
*/
public function findById($id)
{
Expand Down Expand Up @@ -94,6 +95,6 @@ private function extractDetailUrlFromCrawler(Crawler $crawler)
return false;
}

return self::URL_BASE.$href[1];
return self::URL_BASE . $href[1];
}
}
1 change: 1 addition & 0 deletions src/Justice/JusticeRecord.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

final class JusticeRecord
{

/**
* @var array|Person[]
*/
Expand Down
1 change: 1 addition & 0 deletions src/Justice/SubjectNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@

final class SubjectNotFoundException extends Exception
{

}
1 change: 1 addition & 0 deletions src/Parser/DateTimeParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

final class DateTimeParser
{

/**
* @var string[]
*/
Expand Down
1 change: 1 addition & 0 deletions src/Parser/Helper/StringHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

final class StringHelper
{

/**
* @param string $text
*
Expand Down
1 change: 1 addition & 0 deletions src/Parser/JusticeJednatelPersonParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

final class JusticeJednatelPersonParser
{

/**
* @param 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 @@ -8,6 +8,7 @@

final class JusticeSpolecnikPersonParser
{

/**
* @param Crawler $crawler
*
Expand Down
1 change: 1 addition & 0 deletions src/ValueObject/Person.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

final class Person
{

/**
* @var string
*/
Expand Down
19 changes: 10 additions & 9 deletions tests/AresTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

final class AresTest extends TestCase
{

/**
* @var Ares
*/
Expand Down Expand Up @@ -39,12 +40,12 @@ public function testFindByIdentificationNumberWithLeadingZeros()
public function testFindByIdentificationNumberException()
{
$this->expectException(\Webnazakazku\Ares\AresException::class);
$this->ares->findByIdentificationNumber('A1234');
$this->ares->findByIdentificationNumber('A1234');
}

public function testFindByEmptyStringException()
{
$this->expectException(\Webnazakazku\Ares\AresException::class);
$this->expectException(\Webnazakazku\Ares\AresException::class);
$this->ares->findByIdentificationNumber('');
}

Expand All @@ -57,10 +58,10 @@ public function testFindByName()

public function testFindByNameNonExistentName()
{
$this->expectException(\Webnazakazku\Ares\AresException::class);
$this->expectExceptionMessage('Nic nebylo nalezeno.');
$this->expectException(\Webnazakazku\Ares\AresException::class);
$this->expectExceptionMessage('Nic nebylo nalezeno.');

$this->ares->findByName('some non-existent company name');
$this->ares->findByName('some non-existent company name');
}

public function testGetCompanyPeople()
Expand All @@ -77,9 +78,9 @@ public function testGetCompanyPeople()

public function testBalancer()
{
if ($this->isCI()) {
$this->markTestSkipped('GitHun Actions cannot connect to Justice.cz');
}
if ($this->isCI()) {
$this->markTestSkipped('GitHun Actions cannot connect to Justice.cz');
}

$ares = new Ares();
$ares->setBalancer('http://some.loadbalancer.domain');
Expand All @@ -90,7 +91,7 @@ public function testBalancer()
}
$this->assertEquals(
'http://some.loadbalancer.domain'
.'?url=http%3A%2F%2Fwwwinfo.mfcr.cz%2Fcgi-bin%2Fares%2Fdarv_bas.cgi%3Fico%3D26168685',
. '?url=http%3A%2F%2Fwwwinfo.mfcr.cz%2Fcgi-bin%2Fares%2Fdarv_bas.cgi%3Fico%3D26168685',
$ares->getLastUrl()
);
}
Expand Down
Loading

0 comments on commit e5b821d

Please sign in to comment.