Skip to content

Commit

Permalink
Huge code reformat for PSR12 comply
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitexus committed Oct 12, 2023
1 parent d8395b5 commit 584aa14
Show file tree
Hide file tree
Showing 44 changed files with 6,399 additions and 6,196 deletions.
4,883 changes: 2,442 additions & 2,441 deletions src/AbraFlexi/Actions.php

Large diffs are not rendered by default.

33 changes: 19 additions & 14 deletions src/AbraFlexi/Adresar.php
Expand Up @@ -6,6 +6,7 @@
* @author Vítězslav Dvořák <vitex@arachne.cz>
* @copyright (C) 2015-2023 Spoje.Net
*/

declare(strict_types=1);

namespace AbraFlexi;
Expand All @@ -17,7 +18,6 @@
*/
class Adresar extends RW
{

use stitky;
use subItems;
use firma;
Expand All @@ -38,8 +38,10 @@ class Adresar extends RW
public function getNotificationEmailAddress()
{
$email = null;
$emailsRaw = $this->getFlexiData($this->getApiURL(),
['detail' => 'custom:id,email,kontakty(primarni,email)', 'relations' => 'kontakty']);
$emailsRaw = $this->getFlexiData(
$this->getApiURL(),
['detail' => 'custom:id,email,kontakty(primarni,email)', 'relations' => 'kontakty']
);
if (is_array($emailsRaw) && !empty($emailsRaw[0])) {
$emails = $emailsRaw[0];
if (array_key_exists('email', $emails) && strlen(trim($emails['email']))) {
Expand All @@ -59,14 +61,16 @@ public function getNotificationEmailAddress()

/**
* get cell phone Number for Customer with primary contact prefered
*
*
* @return string cell phone number of primary contact or address cell number or null
*/
public function getCellPhoneNumber()
{
$mobil = null;
$mobilsRaw = $this->getFlexiData($this->getApiURL(),
['detail' => 'custom:id,mobil,kontakty(primarni,mobil)', 'relations' => 'kontakty']);
$mobilsRaw = $this->getFlexiData(
$this->getApiURL(),
['detail' => 'custom:id,mobil,kontakty(primarni,mobil)', 'relations' => 'kontakty']
);
if (is_array($mobilsRaw)) {
$mobils = $mobilsRaw[0];
if (array_key_exists('mobil', $mobils) && strlen(trim($mobils['mobil']))) {
Expand All @@ -86,14 +90,16 @@ public function getCellPhoneNumber()

/**
* get any phone Number for Customer with primary contact prefered
*
*
* @return string phone number of primary contact or address's phone number or null
*/
public function getAnyPhoneNumber()
{
$phoneNo = null;
$numbersRaw = $this->getFlexiData($this->getApiURL(),
['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']);
$numbersRaw = $this->getFlexiData(
$this->getApiURL(),
['detail' => 'custom:id,mobil,tel,kontakty(primarni,mobil,tel)', 'relations' => 'kontakty']
);
if (is_array($numbersRaw) && !empty($numbersRaw[0])) {
$numbers = $numbersRaw[0];
if (array_key_exists('mobil', $numbers) && strlen(trim($numbers['mobil']))) {
Expand All @@ -103,7 +109,6 @@ public function getAnyPhoneNumber()
$phoneNo = $numbers['tel'];
}
if (array_key_exists('kontakty', $numbers) && !empty($numbers['kontakty'])) {

// Try to use primary contact if present
foreach ($numbers['kontakty'] as $kontakt) {
if ($kontakt['primarni'] == 'true') {
Expand All @@ -129,10 +134,10 @@ public function getAnyPhoneNumber()
}

/**
* Obtain Bank number
*
* Obtain Bank number
*
* @param Adresar|string|int $address
*
*
* @return array bank account details
*/
public function getBankAccountNumber($address = null)
Expand All @@ -143,4 +148,4 @@ public function getBankAccountNumber($address = null)
$bucRaw = $this->getColumnsFromAbraFlexi(['buc', 'smerKod'], ['firma' => $address, 'evidence' => 'adresar-bankovni-ucet']);
return (!empty($bucRaw) && array_key_exists(0, $bucRaw)) ? $bucRaw : [];
}
}
}
30 changes: 18 additions & 12 deletions src/AbraFlexi/Changes.php
Expand Up @@ -18,8 +18,8 @@
*
* @link https://www.abraflexi.eu/api/dokumentace/ref/changes-api/ Dokumentace
*/
class Changes extends RO {

class Changes extends RO
{
/**
* Evidence užitá objektem.
*
Expand All @@ -30,21 +30,23 @@ class Changes extends RO {
/**
* Povolí oznamování změn
* Allow changes notification
*
*
* @return boolean
*/
public function enable() {
public function enable()
{
$this->performRequest('enable.xml', 'POST', 'xml');
return $this->lastResponseCode == 200;
}

/**
* Zakáže oznamování změn
* Disallow changes notification
*
*
* @return boolean
*/
public function disable() {
public function disable()
{
$this->performRequest('disable.xml', 'POST', 'xml');
return $this->lastResponseCode == 200;
}
Expand All @@ -54,7 +56,8 @@ public function disable() {
*
* @return boolean
*/
public function getStatus() {
public function getStatus()
{
$status = $this->performRequest('status.xml', 'GET', 'xml');
return (($this->lastResponseCode == 200) && ($status['changes'][0]['success'] === 'true'));
}
Expand All @@ -65,7 +68,8 @@ public function getStatus() {
* @param array $data
* @return null Method is disabled for Changes
*/
public function recordExists($data = null) {
public function recordExists($data = null)
{
return null;
}

Expand All @@ -76,7 +80,8 @@ public function recordExists($data = null) {
* @link https://www.abraflexi.eu/api/dokumentace/ref/changes-api#globalVersion Globální Verze
* @return int
*/
public function getGlobalVersion() {
public function getGlobalVersion()
{
$this->getColumnsFromAbraFlexi('id', ['start' => 0, 'limit' => 0]);
return $this->globalVersion;
}
Expand All @@ -88,7 +93,8 @@ public function getGlobalVersion() {
*
* @return array
*/
public function rawXmlToArray($rawXML) {
public function rawXmlToArray($rawXML)
{
return [$this->getEvidence() => parent::rawXmlToArray($rawXML)];
}

Expand All @@ -97,8 +103,8 @@ public function rawXmlToArray($rawXML) {
*
* @return null
*/
public function getVazby($id = null) {
public function getVazby($id = null)
{
throw new Exception(_('Changes has no relations'), $this);
}

}
27 changes: 13 additions & 14 deletions src/AbraFlexi/Document.php
Expand Up @@ -9,7 +9,6 @@
* @copyright (C) 2015-2023 Spoje.Net
*/


namespace AbraFlexi;

/**
Expand All @@ -20,16 +19,16 @@ interface Document
{
/**
* Get all labels for current record
*
*
* @return array
*/
public function getLabels();

/**
* Set one of availble Labels for current record
*
*
* @param string $label
*
*
* @return boolean Operation success
*/
public function setLabel($label);
Expand All @@ -49,16 +48,16 @@ public function unsetLabel($labelsToRemove);
* @return boolean success result ?
*/
public function unsetLabels();

/**
* Instance of Adresar( $this->getDataValue('firma') )
*
* Instance of Adresar( $this->getDataValue('firma') )
*
* @param array $options for new Object
*
*
* @return Adresar
*/
public function getFirmaObject($options = ['details' => 'id']);

/**
* Vrací z AbraFlexi sumaci i podle podmínek.
*
Expand All @@ -67,10 +66,10 @@ public function getFirmaObject($options = ['details' => 'id']);
* @return array
*/
public function getSumFromAbraFlexi($conditions = []);

/**
* Subitems - ex. items of invoice
*
*
* @return array of document items or null
*/
public function getSubItems();
Expand All @@ -94,15 +93,15 @@ public function getSubMenuName();
* @return \AbraFlexi\RW
*/
public function getSubObjects();

/**
* Get recipient for documnet.
*
*
* 1. try Document's "kontaktEmail" field
* 2. try Document's company email
* 3. try Document's primary contact mail
* 4. try Document's any contact mail
*
*
* @return string
*/
public function getEmail();
Expand Down
49 changes: 30 additions & 19 deletions src/AbraFlexi/Evidence.php
Expand Up @@ -19,51 +19,62 @@
*
* @author Vítězslav Dvořák <info@vitexsoftware.cz>
*/
class Evidence extends Sand {

class Evidence extends Sand
{
/**
*
* @var RO
* @var RO
*/
public $engine = null;

/**
*
* @var array
* @var array
*/
public $conditions = [];

/**
*
*
* @param RO $engine
*
*
* @param array $conditions
*/
public function __construct(RO $engine, array $conditions = []) {
public function __construct(RO $engine, array $conditions = [])
{
$this->engine = $engine;
$this->conditions = $conditions;
}

/**
* Array of objects in eveidence
*
*
* @return array
*/
public function getEvidenceData() {
return $this->engine->getColumnsFromAbraFlexi(array_key_exists('detail',
$this->conditions) ? $this->conditions['detail'] : 'full', $this->conditions);
public function getEvidenceData()
{
return $this->engine->getColumnsFromAbraFlexi(array_key_exists(
'detail',
$this->conditions
) ? $this->conditions['detail'] : 'full', $this->conditions);
}

/**
* Array of objects in eveidence
*
*
* @return RO[]
*/
public function getEvidenceObjects() {
public function getEvidenceObjects()
{
$contents = [];
foreach ($this->engine->getColumnsFromAbraFlexi(array_key_exists('detail',
$this->conditions) ? $this->conditions['detail'] : 'full',
$this->conditions) as $pos => $recordData) {
foreach (
$this->engine->getColumnsFromAbraFlexi(
array_key_exists(
'detail',
$this->conditions
) ? $this->conditions['detail'] : 'full',
$this->conditions
) as $pos => $recordData
) {
$contents[$pos] = clone $this->engine;
$contents[$pos]->setData($recordData, true);
}
Expand All @@ -72,11 +83,11 @@ public function getEvidenceObjects() {

/**
* get used evidence name
*
*
* @return string
*/
public function getEvidence() {
public function getEvidence()
{
return $this->engine->getEvidence();
}

}

0 comments on commit 584aa14

Please sign in to comment.