ImageController   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
eloc 5
c 2
b 0
f 1
dl 0
loc 32
rs 10
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A comments() 0 3 1
A comment() 0 3 1
1
<?php
2
3
namespace FaithGen\SDK\Http\Controllers;
4
5
use FaithGen\Gallery\Http\Requests\ImageCommentRequest;
0 ignored issues
show
Bug introduced by
The type FaithGen\Gallery\Http\Requests\ImageCommentRequest was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use FaithGen\SDK\Helpers\CommentHelper;
7
use FaithGen\SDK\Models\Image;
8
use FaithGen\SDK\Services\ImageService;
9
use Illuminate\Http\Request;
10
use Illuminate\Routing\Controller;
11
12
class ImageController extends Controller
13
{
14
    protected $imageService;
15
16
    public function __construct(ImageService $imageService)
17
    {
18
        $this->imageService = $imageService;
19
    }
20
21
    /**
22
     * Sends a comment to an image.
23
     *
24
     * @param \FaithGen\Gallery\Http\Requests\ImageCommentRequest $request
25
     *
26
     * @return \Illuminate\Http\JsonResponse
27
     */
28
    public function comment(ImageCommentRequest $request)
29
    {
30
        return CommentHelper::createComment($this->imageService->getImage(), $request);
31
    }
32
33
    /**
34
     * Fetches the comments for this image.
35
     *
36
     * @param \Illuminate\Http\Request $request
37
     * @param \FaithGen\SDK\Models\Image $image
38
     *
39
     * @return \Illuminate\Http\Resources\Json\AnonymousResourceCollection
40
     */
41
    public function comments(Request $request, Image $image)
42
    {
43
        return CommentHelper::getComments($image, $request);
44
    }
45
}
46