Code Duplication    Length = 22-22 lines in 2 locations

src/Core/Component/User/Application/Repository/DQL/UserRepository.php 2 locations

@@ 129-150 (lines=22) @@
126
    /**
127
     * @return User[]
128
     */
129
    public function findAllByCommentId(
130
        CommentId $commentId,
131
        array $orderByList = ['id' => 'DESC'],
132
        int $maxResults = null
133
    ): ResultCollectionInterface {
134
135
        $this->dqlQueryBuilder->create(User::class);
136
137
        $this->dqlQueryBuilder->innerJoin(Comment::class, 'Comment', Join::WITH, 'Comment.authorId = User.id')
138
            ->where('Comment.id = :comment')
139
            ->setParameter('comment', $commentId);
140
141
        foreach ($orderByList as $property => $direction) {
142
            $this->dqlQueryBuilder->orderBy('User.' . $property, $direction);
143
        }
144
145
        if ($maxResults) {
146
            $this->dqlQueryBuilder->setMaxResults($maxResults);
147
        }
148
149
        return $this->queryService->query($this->dqlQueryBuilder->build());
150
    }
151
152
    /**
153
     * @return User[]
@@ 155-176 (lines=22) @@
152
    /**
153
     * @return User[]
154
     */
155
    public function findAllByPostId(
156
        PostId $postId,
157
        array $orderByList = ['id' => 'DESC'],
158
        int $maxResults = null
159
    ): ResultCollectionInterface {
160
161
        $this->dqlQueryBuilder->create(User::class);
162
163
        $this->dqlQueryBuilder->innerJoin(Post::class, 'Post', Join::WITH, 'Post.authorId = User.id')
164
            ->where('Post.id = :post')
165
            ->setParameter('post', $postId);
166
167
        foreach ($orderByList as $property => $direction) {
168
            $this->dqlQueryBuilder->orderBy('User.' . $property, $direction);
169
        }
170
171
        if ($maxResults) {
172
            $this->dqlQueryBuilder->setMaxResults($maxResults);
173
        }
174
175
        return $this->queryService->query($this->dqlQueryBuilder->build());
176
    }
177
}
178