Passed
Push — master ( a5a3c9...cc0a46 )
by Julito
17:31
created

CForumRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 11 3
A __construct() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CourseBundle\Repository;
8
9
use Chamilo\CoreBundle\Entity\ResourceInterface;
10
use Chamilo\CoreBundle\Repository\ResourceRepository;
11
use Chamilo\CourseBundle\Entity\CForum;
12
use Doctrine\Persistence\ManagerRegistry;
13
14
final class CForumRepository extends ResourceRepository
15
{
16
    public function __construct(ManagerRegistry $registry)
17
    {
18
        parent::__construct($registry, CForum::class);
19
    }
20
21
    public function delete(ResourceInterface $resource): void
22
    {
23
        /** @var CForum $resource */
24
        $threads = $resource->getThreads();
25
        if (!empty($threads)) {
26
            foreach ($threads as $thread) {
27
                parent::delete($thread);
28
            }
29
        }
30
31
        parent::delete($resource);
32
    }
33
}
34