Code Duplication    Length = 12-13 lines in 3 locations

src/Controller/PostController.php 3 locations

@@ 115-126 (lines=12) @@
112
     * @param string $slug
113
     * @return string
114
     */
115
    public function category(ServerRequestInterface $request, $slug)
116
    {
117
        $paginator = $this->paginatorBuilder->build($request, $this->posts->byCategoryCount($slug));
118
119
        $posts = $this->posts->byCategory($slug, $paginator->getPage(), $paginator->getPerPage());
120
121
        return $this->view('index.twig', [
122
            'posts' => $posts,
123
            'paginator' => $paginator,
124
            'title' => 'Posty w kategorii \''.$posts[0]->getCategory()->getName().'\''
125
        ]);
126
    }
127
128
    /**
129
     * /tag/{slug}
@@ 135-146 (lines=12) @@
132
     * @param string $slug
133
     * @return string
134
     */
135
    public function tag(ServerRequestInterface $request, $slug)
136
    {
137
        $paginator = $this->paginatorBuilder->build($request, $this->posts->byTagCount($slug));
138
139
        $posts = $this->posts->byTag($slug, $paginator->getPage(), $paginator->getPerPage());
140
141
        return $this->view('index.twig', [
142
            'posts' => $posts,
143
            'paginator' => $paginator,
144
            'title' => 'Posty otagowane \''.$slug.'\''
145
        ]);
146
    }
147
148
    /**
149
     * /?q={term}
@@ 155-167 (lines=13) @@
152
     * @param string $term
153
     * @return string
154
     */
155
    public function search(ServerRequestInterface $request, $term)
156
    {
157
        $paginator = $this->paginatorBuilder->build($request, $this->posts->searchCount($term));
158
159
        $posts = $this->posts->search($term, $paginator->getPage(), $paginator->getPerPage());
160
161
        return $this->view('index.twig', [
162
            'posts' => $posts,
163
            'paginator' => $paginator,
164
            'title' => 'Wyniki wyszukiwania dla \''.$term.'\'',
165
            'searchTerm' => $term
166
        ]);
167
    }
168
}
169