Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PES-1251, PES-2068, PES-2080 Default weight and packet dimensions #78

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

Mrakor
Copy link
Contributor

@Mrakor Mrakor commented Apr 24, 2024

No description provided.

install.sql Outdated Show resolved Hide resolved
media/admin/com_virtuemart/controllers/zasilkovna.php Outdated Show resolved Hide resolved
media/admin/com_virtuemart/controllers/zasilkovna.php Outdated Show resolved Hide resolved
media/admin/com_virtuemart/models/zasilkovna_orders.php Outdated Show resolved Hide resolved
media/admin/com_virtuemart/models/zasilkovna_orders.php Outdated Show resolved Hide resolved
zasilkovna.php Outdated Show resolved Hide resolved
zasilkovna.php Outdated Show resolved Hide resolved
@zemekoule zemekoule changed the title PES-1251 Default weight and packet dimensions PES-1251, PES-2068 Default weight and packet dimensions May 3, 2024
Mrakor added 2 commits May 3, 2024 13:34
PES-2068 CR refactor - introduce constants
PES-2068 CR fix - unused getters removed
PES-2068 CR fix - format table using css
PES-2068 CR fix - typehints & annotations
PES-2068 CR fix - introduce updateZasilkovnaConfig
PES-2068 CR fix - introduce configuration defaults
PES-2068 final minor CR fixes
PES-2068 CS fixes and minor improvement
PES-2068 Use ConfigValidator::KEY_PAYMENT_METHOD_PREFIX in template
PES-2068 CR - final fix for strange VM null handling
@Mrakor Mrakor force-pushed the PES-1251_default_weight_and_packet_dimensions branch from 137ff3e to 9b8f1d3 Compare May 3, 2024 11:35
Mrakor added 2 commits May 9, 2024 17:11
introduce ConfigConstants
introduce ConfigurationValidator::normalize
@zemekoule zemekoule changed the title PES-1251, PES-2068 Default weight and packet dimensions PES-1251, PES-2068, PES-2080 Default weight and packet dimensions May 14, 2024
@zemekoule zemekoule requested review from xpavp03 and zemekoule May 15, 2024 09:23
*/
private function updateZasilkovnaConfig(array $data): FlashMessage
{
$configStorage = new VirtueMartModelZasilkovna\ConfigSessionStorage(JFactory::getSession(), 'packeteryConfig');
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

namespace by měl být uvnitř třídy ConfigSessionStorage - je součástí zapouzdření ukládací logiky

a pojmenuj $configSessionStorage, ať je níže jasnější, kam ukládáme a kde mažeme (dtto ve view.html.php)

$this->set(self::ID, self::KEY, $data);
}

public function flush(): void
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

raději clear() nebo removeAll()
flush() u Doctrine znamená uložit změny, radši bych zvolil jednoznačnější pojmenování


$normalizedData = [];
$normalizedData[ConfigConstants::KEY_API_PASS] = $this->formData[ConfigConstants::KEY_API_PASS];
$normalizedData[ConfigConstants::KEY_ESHOP_LABEL] = $this->formData[ConfigConstants::KEY_ESHOP_LABEL] ?? ConfigConstants::CONFIG_DEFAULTS[ConfigConstants::KEY_ESHOP_LABEL];
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Používání defaultního labelu je zde zbytečné. Odeslaný formulář má hodnotu vždy (byť třeba prázdný string), takže kontrola přes ?? je zbytečná. Odstraň, prosím, default (+ viz naše diskuse o defaultech jako lokální proměnné v install).

private array $errors = [];

/**
* @param array<string, mixed> $formData
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hodnoty mohou být jen stringy, je to POST


private function validateDimensions(): void {
foreach (self::DIMENSIONS as $field => $label) {
if ((!empty($this->formData[$field]) || $this->formData[$field] === '0')
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

jednodušší testovat jen !== ''
místo !empty() || === '0'

$size[$dimension] = $order[$dimension];
}

if ($order['length']) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tahle podmínka patří nad celé sestavování $size

/**
* @param string $name
* @param mixed $default
* @return array|mixed|string
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@return mixed stačí - a proto úplně odstranit celý PHPDoc, protože nepřináší nic navíc

* @param mixed $default
* @return array|mixed|string
*/
public function getFormValue(string $name, mixed $default = ''): mixed
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mixed $default je v našem případě zbytečně široké

<?php
namespace VirtueMartModelZasilkovna;

class ConfigurationValidator
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Obecně se mi tyto metody špatně čtou, řádky jsou dlouhé, ify obsahují hodně logických prvků.
Tj. aspoň zalamovat, ale ještě lépe vyčleňovat kusy logiky do samostatně pojmenovaných proměnných např. $useDefaultDimensions -> if ($useDefaultDimension && ...)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants