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

FoldersProvider   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 7
lcom 0
cbo 2
dl 40
loc 40
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getProvidedClassname() 4 4 1
A getDefaultCriteria() 4 4 1
A getDefaultOrdering() 4 4 1
A supports() 8 8 2
A toExplorerItem() 7 7 2

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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