Passed
Branch develop (7f369c)
by Nicolas
04:17
created

ProfilesUnfollowController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controller\Api;
4
5
use App\Entity\User;
6
use Doctrine\ORM\EntityManagerInterface;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8
use Symfony\Component\Routing\Annotation\Route;
9
use Symfony\Component\Security\Core\User\UserInterface;
10
11
/**
12
 * @Route("/api/profiles/{username}/follow", name="api_profiles_unfollow")
13
 * @Method("DELETE")
14
 */
15
class ProfilesUnfollowController
16
{
17
    /**
18
     * @var EntityManagerInterface
19
     */
20
    private $manager;
21
22
    /**
23
     * @param EntityManagerInterface $manager
24
     */
25 1
    public function __construct(EntityManagerInterface $manager)
26
    {
27 1
        $this->manager = $manager;
28 1
    }
29
30
    /**
31
     * @param UserInterface $user
32
     * @param User          $profile
33
     *
34
     * @return array
35
     */
36 1
    public function __invoke(UserInterface $user, User $profile)
37
    {
38
        /* @var User $user */
39
40 1
        $user->unfollow($profile);
41 1
        $this->manager->flush();
42
43 1
        return ['profile' => $profile];
44
    }
45
}
46