SearchController::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
nc 1
nop 1
1
<?php
2
3
namespace App\Project\Http\Controller;
4
5
6
use App\Project\App\Support\FractalService;
7
use App\Project\Domain\Article\ArticleService;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use Symfony\Component\HttpFoundation\Request;
10
use Swagger\Annotations as SWG;
11
use Symfony\Component\HttpFoundation\Response;
12
13
class SearchController
14
{
15
16
17
    /**
18
     * @var ArticleService
19
     */
20
    private $articleService;
21
22
23
    public function __construct(ArticleService $articleService)
24
    {
25
        $this->articleService = $articleService;
26
    }
27
28
    /**
29
     * @param Request $request
30
     * @return JsonResponse
31
     * @SWG\Response(
32
     *     response=200,
33
     *     description="Returns the article collection"
34
     * )
35
     * @SWG\Parameter(
36
     *     name="query",
37
     *     in="query",
38
     *     type="string",
39
     *     description="search query"
40
     * )
41
     * @SWG\Tag(name="search")
42
     */
43
    public function index(Request $request)
44
    {
45
        $resource = $this->articleService->searchArticle($request);
46
47
        return new JsonResponse($resource);
48
49
    }
50
}