FolderManager::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 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