-
Notifications
You must be signed in to change notification settings - Fork 85
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
Nova2 refactoring #62
base: master
Are you sure you want to change the base?
Conversation
```php | ||
$np = new \LisDev\Delivery\NovaPoshtaApi2('Ваш_ключ_API_2.0'); | ||
$np = new \LisDev\Controllers\NovaPoshtaApi2('Ваш_ключ_API_2.0'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не совсем понимаю зачем менять неймспейс, если прошлый вполне отражал свое назначение, а вот Controllers может вводить в заблуждение
src/Common/Format.php
Outdated
|
||
class Format | ||
{ | ||
public string $format; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Почему свойство публичное если у него есть сеттер и геттер?
src/Common/Format.php
Outdated
* | ||
* @return NovaPoshtaApi2 | ||
*/ | ||
public function setFormat($format): Format |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
тайпхинтинг аргументов
$this->throwErrors = $throwErrors; | ||
$this | ||
->setKey($key) | ||
->setLanguage($language) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
в этом классе разве есть такой метод?
* | ||
* @see https://my.novaposhta.ua/settings/index#apikeys | ||
*/ | ||
protected $key; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
пхп 8 позволяет типизировать свойства, чем советую активно пользоваться
class AddressService | ||
{ | ||
private PreparationDataService $preparationDataService; | ||
private NovaPoshtaApiClient $novaPoshtaApiClient; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зависимости от реализаций
src/Services/AddressService.php
Outdated
*/ | ||
public function findNearestWarehouse($searchStringArray) | ||
{ | ||
$searchStringArray = (array) $searchStringArray; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
зачем его приводить к массиву если можно указать в хинтиге что это массив
// Try to find current region | ||
foreach ($areas as $key => $area) { | ||
// Is current area found by string or by key | ||
$found = $findByString |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А вот если бы это вынести в метод 'IsAreaFounded(...): bool` то и комментарий не нужен был бы
public function getArea($findByString = '', $ref = '') | ||
{ | ||
// Load areas list from file | ||
empty($this->areas) and $this->areas = (include dirname(__FILE__) . '/NovaPoshtaApi2Areas.php'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
жесткие зависимости и выполнение операций в проверках, плохая практика
|
||
class Model implements ModelInterface | ||
{ | ||
protected Model $model; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Довольно странная абстракция, модель хранит модель чтобы иметь иметь возможность выполнять с ней операции
Nova2 refactoring