Completed
Push — master ( 1a9043...984777 )
by Valentyn
08:31
created

GuestSessionController::postGuests()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 6
nc 1
nop 0
crap 1
1
<?php
2
3
namespace App\Guests\Controller;
4
5
use App\Controller\BaseController;
6
use App\Guests\Entity\GuestSession;
7
use App\Movies\DTO\WatchedMovieDTO;
8
use App\Movies\Entity\Movie;
9
use App\Users\Entity\UserWatchedMovie;
10
use App\Movies\Repository\MovieRepository;
11
use App\Movies\Service\SearchService;
12
use App\Movies\Request\AddWatchedMovieRequest;
13
use App\Movies\Service\WatchedMovieService;
14
use Doctrine\DBAL\Exception\UniqueConstraintViolationException;
15
use Symfony\Component\HttpFoundation\JsonResponse;
16
use Symfony\Component\HttpFoundation\Request;
17
use Symfony\Component\HttpKernel\Exception\BadRequestHttpException;
18
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
19
use Symfony\Component\Routing\Annotation\Route;
20
21
class GuestSessionController extends BaseController
22
{
23
    /**
24
     * @Route("/api/guests", methods={"POST"});
25
     * @return JsonResponse
26
     * @throws \Exception
27
     */
28 1
    public function postGuests()
29
    {
30 1
        $newGuestSession = new GuestSession();
31
32 1
        $em = $this->getDoctrine()->getManager();
33 1
        $em->persist($newGuestSession);
34 1
        $em->flush();
35
36 1
        return $this->response($newGuestSession);
37
    }
38
}