Skip to content

Commit

Permalink
more strict types
Browse files Browse the repository at this point in the history
  • Loading branch information
Vítězslav Dvořák committed Nov 13, 2024
1 parent 937c954 commit 97f006b
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 18 deletions.
10 changes: 3 additions & 7 deletions src/mServer/Adressbook.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,19 @@ class Adressbook extends Client
/**
* Request XML helper.
*/
public \Riesenia\Pohoda\Addressbook $requestXml = null;
public ?\Riesenia\Pohoda\Addressbook $requestXml = null;

/**
* AddressBook records name column.
*/
public string $nameColumn = 'address:company';

/**
* AddressBook records name column.
*/
public string $nameColumn = 'address:company';
public ?string $nameColumn = 'address:company';

/**
* Create Agenda document using given data.
*
* @param array $data
*/
#[\Override]
public function create($data): void
{
$this->requestXml = $this->pohoda->createAddressbook($data);
Expand Down
6 changes: 4 additions & 2 deletions src/mServer/Bank.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class Bank extends Client
*
* @param array $data
*/
#[\Override]
public function create($data): void
{
$this->requestXml = $this->pohoda->createBank($data);
Expand All @@ -62,13 +63,14 @@ public function takeData($data)
\Ease\Functions::divDataArray($data, $summaryData, 'homeCurrency');
\Ease\Functions::divDataArray($data, $summaryData, 'foreignCurrency');
$taken = parent::takeData($data);

return $taken + $this->addSummary($summaryData);
$this->addSummary($summaryData);
return $taken;
}

/**
* {@inheritDoc}
*/
#[\Override]
public function setObjectName($forceName = '')
{
return parent::setObjectName($forceName ?: $this->getDataValue('account').'@'.$this->getObjectName());
Expand Down
10 changes: 3 additions & 7 deletions src/mServer/Client.php
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public function reset(): void
{
$this->dataReset();
$this->pohoda = new Pohoda($this->ico);
$this->pohoda->setApplicationName(Functions::cfg('APP_NAME', 'PHPmPohoda'));
$this->pohoda->setApplicationName(\Ease\Shared::cfg('APP_NAME', 'PHPmPohoda'));
$this->xmlCache = sys_get_temp_dir().'/phpmPohoda_'.Functions::randomString().'.xml';
$this->pohoda->open($this->xmlCache, microtime(), 'generated by PHPmPohoda');

Expand Down Expand Up @@ -543,12 +543,10 @@ public function takeData($data)

/**
* Create Agenda document using given data.
*
* @param array $data
*/
public function create($data)
public function create(string $data)
{
$this->requestXml = $this->pohoda->create($data);
$this->requestXml = $this->pohoda->create($this->agenda, $data);

return empty($this->requestXml) ? 0 : 1;
}
Expand All @@ -557,8 +555,6 @@ public function create($data)
* Insert prepared record to Pohoda.
*
* @param array $data extra data
*
* @return int
*/
public function addToPohoda($data = [])
{
Expand Down
3 changes: 2 additions & 1 deletion src/mServer/Invoice.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class Invoice extends Client
/**
* Request XML helper.
*/
public \Riesenia\Pohoda\Invoice $requestXml = null;
public ?\Riesenia\Pohoda\Invoice $requestXml = null;

/*
public function getElementMap($extra = []) {
Expand Down Expand Up @@ -76,6 +76,7 @@ static function xmlDeserialize(\Sabre\Xml\Reader $reader) {
*
* @param array $data
*/
#[\Override]
public function create($data): void
{
if (\array_key_exists('invoiceSummary', $data)) {
Expand Down
2 changes: 1 addition & 1 deletion tests/update-address.php
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,4 @@
];

$addresser = new Adressbook($addressBookRecord, \Ease\Shared::instanced()->loadConfig(__DIR__.'/.env'));
$addresser->updateInPohoda(null, ['extId' => ['exSystemName' => \Ease\Functions::cfg('APP_NAME'), 'ids' => (string) $extID]]);
$addresser->updateInPohoda(null, ['extId' => ['exSystemName' => \Ease\Shared::cfg('APP_NAME'), 'ids' => (string) $extID]]);

0 comments on commit 97f006b

Please sign in to comment.