Passed
Push — master ( 370563...eb17c3 )
by Angel Fernando Quiroz
10:49 queued 14s
created

UpdateVisibilityLink   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 17
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 10 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Controller\Api;
8
9
use Chamilo\CoreBundle\ServiceHelper\CidReqHelper;
10
use Chamilo\CourseBundle\Entity\CLink;
11
use Chamilo\CourseBundle\Repository\CLinkRepository;
12
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
13
use Symfony\Component\HttpKernel\Attribute\AsController;
14
15
#[AsController]
16
class UpdateVisibilityLink extends AbstractController
17
{
18
    public function __construct(
19
        private readonly CidReqHelper $cidReqHelper,
20
    ) {}
21
22
    public function __invoke(CLink $link, CLinkRepository $repo): CLink
23
    {
24
        $repo->toggleVisibilityPublishedDraft(
25
            $link,
26
            $this->cidReqHelper->getCourseEntity(),
27
            $this->cidReqHelper->getSessionEntity()
28
        );
29
        $link->toggleVisibility();
30
31
        return $link;
32
    }
33
}
34