Completed
Push — master ( 3a917b...8faa80 )
by Alexander
15s queued 12s
created

PostController   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getId() 0 3 1
A index() 0 11 2
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
final 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);
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);
Loading history...
24
        if ($item === null) {
25
            return $this->responseFactory->createResponse(404);
26
        }
27
28
        return $this->render('index', ['item' => $item]);
29
    }
30
}
31