Passed
Pull Request — master (#108)
by Dmitriy
24:06 queued 09:02
created

PostController::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
c 1
b 0
f 0
nc 1
nop 0
dl 0
loc 3
rs 10
1
<?php
2
3
namespace App\Blog\Post;
4
5
use App\Blog\Entity\Post;
6
use App\Controller;
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 static ?string $controllerName = 'blog/post';
14
    public function index(Request $request, ORMInterface $orm): Response
15
    {
16
        $postRepo = $orm->getRepository(Post::class);
17
        $slug = $request->getAttribute('slug', null);
18
19
        $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

19
        /** @scrutinizer ignore-call */ 
20
        $item = $postRepo->fullPostPage($slug);
Loading history...
20
        if ($item === null) {
21
            return $this->responseFactory->createResponse(404);
22
        }
23
24
        return $this->render('index', ['item' => $item]);
25
    }
26
}
27