Passed
Push — master ( 9907da...28a731 )
by Nicolas
05:26
created

FollowProfileController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace App\Controller\Profile;
6
7
use App\Controller\AbstractController;
8
use App\Entity\User;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Security;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
/**
13
 * @Route("/api/profiles/{username}/follow", methods={"POST"}, name="api_profiles_follow")
14
 *
15
 * @Security("is_granted('ROLE_USER')")
16
 */
17
final class FollowProfileController extends AbstractController
18
{
19 1
    public function __invoke(User $profile): array
20
    {
21 1
        $user = $this->getCurrentUser();
22 1
        $user->follow($profile);
23
24 1
        $this->getDoctrine()->getManager()->flush();
25
26 1
        return ['profile' => $profile];
27
    }
28
}
29