Passed
Pull Request — master (#49)
by Alexander
25:24 queued 10:30
created

PostController::index()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 18
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 11
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 18
rs 9.9
1
<?php
2
3
namespace App\Blog\Post;
4
5
use App\Controller;
6
use App\Blog\Entity\Post;
7
use Cycle\ORM\ORMInterface;
8
use Psr\Http\Message\ResponseInterface as Response;
9
use Psr\Http\Message\ServerRequestInterface as Request;
10
11
class PostController extends Controller
12
{
13
    protected function getId(): string
14
    {
15
        return 'blog/post';
16
    }
17
18
    public function index(Request $request, ORMInterface $orm): Response
19
    {
20
        $postRepo = $orm->getRepository(Post::class);
21
        $slug = $request->getAttribute('slug', null);
22
23
        $item = $postRepo->fullPostPage($slug, $this->user->getId());
0 ignored issues
show
Bug introduced by
The method fullPostPage() does not exist on Cycle\ORM\RepositoryInterface. It seems like you code against a sub-type of Cycle\ORM\RepositoryInterface such as App\Blog\Post\PostRepository. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
        /** @scrutinizer ignore-call */ 
24
        $item = $postRepo->fullPostPage($slug, $this->user->getId());
Loading history...
24
        if ($item === null) {
25
            return $this->responseFactory->createResponse(404);
26
        }
27
28
        $data = [
29
            'item' => $item,
30
        ];
31
        $output = $this->render(__FUNCTION__, $data);
32
33
        $response = $this->responseFactory->createResponse();
34
        $response->getBody()->write($output);
35
        return $response;
36
    }
37
}
38