Skip to content

Conversation

KVytyagov
Copy link
Owner

No description provided.

@@ -0,0 +1,65 @@
<?php

Copy link
Owner Author

Choose a reason for hiding this comment

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

не хватает объявления declare(strict_types=1); для строгой проверки входящих параметров функций


class DecoratorManager extends DataProvider
{
public $cache;
Copy link
Owner Author

Choose a reason for hiding this comment

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

нет phpDoc для свойств

область видимости свойства объекта должна быть private, так как оно устанавливается через конструктор. При необходимости замены значения этого свойства после инициализации. лучше использовать соответствующий сеттер как минимум для контроля типа значения в свойстве

аналогично для свойства $logger - у него уже есть сеттер

use Psr\Log\LoggerInterface;
use src\Integration\DataProvider;

class DecoratorManager extends DataProvider
Copy link
Owner Author

Choose a reason for hiding this comment

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

Плохое название класса. По сути, это DataProvider с возможностью использования кэша. Скорее всего это какой-нибудь CachedDataProvider

use Psr\Log\LoggerInterface;
use src\Integration\DataProvider;

class DecoratorManager extends DataProvider
Copy link
Owner Author

Choose a reason for hiding this comment

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

Лучше использовать не наследование, а композицию. Увеличивает переиспользуемость кода

* @param string $password
* @param CacheItemPoolInterface $cache
*/
public function __construct($host, $user, $password, CacheItemPoolInterface $cache)
Copy link
Owner Author

Choose a reason for hiding this comment

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

  1. нет типизации на аргументах $host, $user, $password
  2. в логике реализации заложено обязательное наличие свойства $logger в объекте, поэтому его стоит вынести в конструктор

В случае с использованием композиции. конструктор будет выглядеть так:
public function __construct(DataProviderInterface $dataProvider,CacheItemPoolInterface $cache, LoggerInterface $logger)

* @param $user
* @param $password
*/
public function __construct($host, $user, $password)
Copy link
Owner Author

Choose a reason for hiding this comment

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

не типизированы аргументы

*
* @return array
*/
public function get(array $request)
Copy link
Owner Author

Choose a reason for hiding this comment

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

нет типизации для возвращаемого значения

public function get(array $request): array

/**
* @param array $request
*
* @return array
Copy link
Owner Author

Choose a reason for hiding this comment

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

Если есть возможность. необходимо описать какие типы данных или какую структуру имеет возвращаемый массив

*/
public function get(array $request)
{
// returns a response from external service
Copy link
Owner Author

Choose a reason for hiding this comment

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

тут точно не должно быть реализации?

@@ -0,0 +1,32 @@
<?php

Copy link
Owner Author

Choose a reason for hiding this comment

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

не хватает объявления declare(strict_types=1); для строгой проверки входящих параметров функций

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.

1 participant