weixin_39844590 2020-11-22 01:42
浏览 0

Refactor API from v5 to v6

The main goal of this refactoring is start to use strict types where it is possible and refactor relationships.

Right now API v5 has issue with methods naming because Likeable model cannot act as Liker model in the same time. This could be useful when User can like User.

该提问来源于开源项目:cybercog/laravel-love

  • 写回答

6条回答 默认 最新

  • weixin_39844590 2020-11-22 01:42
    关注

    (?) LikeableService contract

    Old

    php
    public function addLikeTo(Likeable $likeable, $type, $userId);
    public function removeLikeFrom(Likeable $likeable, $type, $userId);
    public function toggleLikeOf(Likeable $likeable, $type, $userId);
    public function isLiked(Likeable $likeable, $type, $userId): bool;
    

    New

    Change methods argument order in LikeableService contract and accept only strict types.

    php
    public function addLikeTo(Likeable $likeable, Liker $user, LikeType $type);
    public function removeLikeFrom(Likeable $likeable, Liker $user, LikeType $type);
    public function toggleLikeOf(Likeable $likeable, Liker $user, LikeType $type);
    public function isLiked(Likeable $likeable, Liker $user, LikeType $type): bool;
    
    评论

报告相同问题?