-
Notifications
You must be signed in to change notification settings - Fork 0
given solution #1
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
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,65 @@ | |||
<?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.
не хватает объявления declare(strict_types=1);
для строгой проверки входящих параметров функций
|
||
class DecoratorManager extends DataProvider | ||
{ | ||
public $cache; |
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.
нет phpDoc для свойств
область видимости свойства объекта должна быть private
, так как оно устанавливается через конструктор. При необходимости замены значения этого свойства после инициализации. лучше использовать соответствующий сеттер как минимум для контроля типа значения в свойстве
аналогично для свойства $logger - у него уже есть сеттер
use Psr\Log\LoggerInterface; | ||
use src\Integration\DataProvider; | ||
|
||
class DecoratorManager extends DataProvider |
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.
Плохое название класса. По сути, это DataProvider с возможностью использования кэша. Скорее всего это какой-нибудь CachedDataProvider
use Psr\Log\LoggerInterface; | ||
use src\Integration\DataProvider; | ||
|
||
class DecoratorManager extends DataProvider |
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.
Лучше использовать не наследование, а композицию. Увеличивает переиспользуемость кода
* @param string $password | ||
* @param CacheItemPoolInterface $cache | ||
*/ | ||
public function __construct($host, $user, $password, CacheItemPoolInterface $cache) |
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.
- нет типизации на аргументах
$host
,$user
,$password
- в логике реализации заложено обязательное наличие свойства
$logger
в объекте, поэтому его стоит вынести в конструктор
В случае с использованием композиции. конструктор будет выглядеть так:
public function __construct(DataProviderInterface $dataProvider,CacheItemPoolInterface $cache, LoggerInterface $logger)
* @param $user | ||
* @param $password | ||
*/ | ||
public function __construct($host, $user, $password) |
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.
не типизированы аргументы
* | ||
* @return array | ||
*/ | ||
public function get(array $request) |
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.
нет типизации для возвращаемого значения
public function get(array $request): array
/** | ||
* @param array $request | ||
* | ||
* @return array |
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.
Если есть возможность. необходимо описать какие типы данных или какую структуру имеет возвращаемый массив
*/ | ||
public function get(array $request) | ||
{ | ||
// returns a response from external service |
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.
тут точно не должно быть реализации?
@@ -0,0 +1,32 @@ | |||
<?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.
не хватает объявления declare(strict_types=1); для строгой проверки входящих параметров функций
No description provided.