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

PostController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 13
c 1
b 0
f 0
dl 0
loc 25
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A index() 0 18 2
A getId() 0 3 1
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