FolderManager   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 55
ccs 12
cts 12
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getFolderHierarchy() 0 4 1
A getRootFolderFor() 0 6 1
A getParentIds() 0 4 1
A getParents() 0 4 1
1
<?php
2
3
namespace Kunstmaan\MediaBundle\Helper;
4
5
use Kunstmaan\MediaBundle\Entity\Folder;
6
use Kunstmaan\MediaBundle\Repository\FolderRepository;
7
8
class FolderManager
9
{
10
    /** @var \Kunstmaan\MediaBundle\Repository\FolderRepository */
11
    private $repository;
12
13
    /**
14
     * @var \Kunstmaan\MediaBundle\Repository\FolderRepository
15
     */
16 4
    public function __construct(FolderRepository $repository)
17
    {
18 4
        $this->repository = $repository;
19 4
    }
20
21
    /**
22
     * @param Folder $rootFolder
23
     *
24
     * @return array|string
25
     */
26 1
    public function getFolderHierarchy(Folder $rootFolder)
27
    {
28 1
        return $this->repository->childrenHierarchy($rootFolder);
29
    }
30
31
    /**
32
     * @param Folder $folder
33
     *
34
     * @return Folder
35
     */
36 1
    public function getRootFolderFor(Folder $folder)
37
    {
38 1
        $parentIds = $this->getParentIds($folder);
39
40 1
        return $this->repository->getFolder($parentIds[0]);
41
    }
42
43
    /**
44
     * @param Folder $folder
45
     *
46
     * @return array
47
     */
48 2
    public function getParentIds(Folder $folder)
49
    {
50 2
        return $this->repository->getParentIds($folder);
51
    }
52
53
    /**
54
     * @param Folder $folder
55
     *
56
     * @return array
57
     */
58 1
    public function getParents(Folder $folder)
59
    {
60 1
        return $this->repository->getPath($folder);
61
    }
62
}
63