Completed
Push — master ( 16c340...4f5273 )
by Ambroise
10:35 queued 05:26
created

FoldersProvider::toExplorerItem()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7

Duplication

Lines 7
Ratio 100 %

Importance

Changes 0
Metric Value
dl 7
loc 7
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Themes\Rozier\Explorer;
5
6
use RZ\Roadiz\Core\Entities\Folder;
7
8 View Code Duplication
final class FoldersProvider extends AbstractDoctrineExplorerProvider
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
9
{
10
    protected function getProvidedClassname(): string
11
    {
12
        return Folder::class;
13
    }
14
15
    protected function getDefaultCriteria(): array
16
    {
17
        return [];
18
    }
19
20
    protected function getDefaultOrdering(): array
21
    {
22
        return ['folderName' =>'ASC'];
23
    }
24
25
    /**
26
     * @inheritDoc
27
     */
28
    public function supports($item)
29
    {
30
        if ($item instanceof Folder) {
31
            return true;
32
        }
33
34
        return false;
35
    }
36
37
    /**
38
     * @inheritDoc
39
     */
40
    public function toExplorerItem($item)
41
    {
42
        if ($item instanceof Folder) {
43
            return new FolderExplorerItem($item);
44
        }
45
        throw new \InvalidArgumentException('Explorer item must be instance of ' . Folder::class);
46
    }
47
}
48