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

ArticlesDeleteController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 23
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __invoke() 0 4 1
1
<?php
2
3
namespace App\Controller\Api;
4
5
use App\Entity\Article;
6
use Doctrine\ORM\EntityManagerInterface;
7
use FOS\RestBundle\Controller\Annotations\View;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
10
use Symfony\Component\Routing\Annotation\Route;
11
use Symfony\Component\Security\Core\User\UserInterface;
12
13
/**
14
 * ArticlesDeleteController.
15
 *
16
 * @Route("/api/articles/{slug}", name="api_articles_delete")
17
 * @Method("DELETE")
18
 * @View(statusCode=204)
19
 * @IsGranted("OWNER", subject="article")
20
 */
21
class ArticlesDeleteController
22
{
23
    /**
24
     * @var EntityManagerInterface
25
     */
26
    protected $manager;
27
28
    /**
29
     * @param EntityManagerInterface $manager
30
     */
31 2
    public function __construct(EntityManagerInterface $manager)
32
    {
33 2
        $this->manager = $manager;
34 2
    }
35
36
    /**
37
     * @param UserInterface $user
38
     * @param Article       $article
39
     */
40 1
    public function __invoke(UserInterface $user, Article $article)
41
    {
42 1
        $this->manager->remove($article);
43 1
        $this->manager->flush();
44 1
    }
45
}
46