Passed
Push — master ( d88203...94a809 )
by Julito
07:42
created

CForumForumRepository   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

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

2 Methods

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