K kamischin/hw13#234
Conversation
|
|
||
| namespace App\Domain\News\Repositories; | ||
|
|
||
| use App\Domain\News\Entities\News as DomainNews; |
There was a problem hiding this comment.
Тут вроде других News нет.. можно было и не делать alias
| * @param int $limit | ||
| * @param int $offset | ||
| * | ||
| * @return array |
| public function fetchAll(): array; | ||
|
|
||
| /** | ||
| * @param int $limit |
|
|
||
| namespace App\Domain\News\Services; | ||
|
|
||
| interface CategorySlugGeneratorInterface |
There was a problem hiding this comment.
Тут сервис инфраструктурный скорее - такое относится к слою Application. В доменном слое сервисы это классы, которые какую-то чисто бизнес логику содержат надо более чем одним агрегатом, без инфраструктурных зависимостей
|
|
||
| use Exception; | ||
|
|
||
| final class UserNotFoundException extends Exception |
There was a problem hiding this comment.
Для доменных исключений есть базовый класс DomainException, лучше от него наследоваться
|
|
||
| namespace App\Domain\User\ValueObjects; | ||
|
|
||
| final class Permissions |
There was a problem hiding this comment.
не очень удачный кандидат на ValueObject, обычно VO не бывают коллекциями..
|
|
||
| final class Permissions | ||
| { | ||
| public function __construct(public array $permissions) {} |
| * Create a new event instance. | ||
| */ | ||
| public function __construct(News $news) | ||
| public function __construct(readonly public int $id, readonly public string $title, readonly public string $content) |
There was a problem hiding this comment.
нечитабельно. Поставьте себе пакет php-cs-fixer, он вам сам будет стиль править по psr
| ->limit($limit) | ||
| ->get(); | ||
|
|
||
| return array_map([NewsMapper::class, 'toEntity'], $models->all()); |
There was a problem hiding this comment.
методы строковыми литералами вам рефакторинг превратят в ад, уж лучше коллбек функцию передать и там явно дергать Mapper::toEntity()
| $model->{$model->getColumnName('id')} = $news->getId(); | ||
| } | ||
|
|
||
| $model->{$model->getColumnName('title')} = $news->getTitle(); |
There was a problem hiding this comment.
Вот тут не понимаю, зачем вы эту конструкцию используете?
$model->{$model->getColumnName('title')} это ж адок в плане читабельности...
В eloquent к свойствам обращаются так: $model->title.
Если бы вы трижды не проигнорировали мой комментарий в предыдущей домашке по разметке сущности доклблоками @property string $title вам было бы тут гораздо проще.
| use App\Models\Category as EloquentCategory; | ||
| use App\Models\User as EloquentUser; | ||
|
|
||
| class NewsMapper |
No description provided.