Completed
Pull Request — master (#24)
by Jason
10:50
created

OperationManual   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 76
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 3
dl 76
loc 76
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getCMSFields() 8 8 1
A providePermissions() 8 8 1
A canCreate() 4 4 1
A canEdit() 4 4 1
A canDelete() 4 4 1

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
3
namespace Dynamic\ProductCatalog\Docs;
4
5
use SilverStripe\Security\Permission;
6
use SilverStripe\Security\PermissionProvider;
7
8 View Code Duplication
class OperationManual extends ProductDoc implements PermissionProvider
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
    /**
11
     * @var string
12
     */
13
    private static $singular_name = 'Operation Manual';
14
15
    /**
16
     * @var string
17
     */
18 1
    private static $plural_name = 'OperationManuals';
19
20 1
    /**
21
     * @var string
22 1
     */
23
    private static $table_name = 'OperationManual';
0 ignored issues
show
Unused Code introduced by
The property $table_name is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
24 1
25
    /**
26
     * @return FieldList
27
     */
28
    public function getCMSFields()
29
    {
30 1
        $fields = parent::getCMSFields();
31
32
        $fields->dataFieldByName('Download')->setFolderName('Uploads/Products/OperationManuals');
33 1
34 1
        return $fields;
35 1
    }
36 1
37
    /**
38
     * @return array
39
     */
40
    public function providePermissions()
41
    {
42
        return array(
43
            'Operation_EDIT' => 'Edit Operation Manuals',
44 1
            'Operation_DELETE' => 'Delete Operation Manuals',
45
            'Operation_CREATE' => 'Create Operation Manuals',
46 1
        );
47
    }
48
49
    /**
50
     * @param null $member
51
     *
52
     * @return bool|int
53
     */
54 1
    public function canCreate($member = null, $context = [])
55
    {
56 1
        return Permission::check('Operation_CREATE', 'any', $member);
57
    }
58
59
    /**
60
     * @param null $member
61
     *
62
     * @return bool|int
63
     */
64 1
    public function canEdit($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
65
    {
66 1
        return Permission::check('Operation_EDIT', 'any', $member);
67
    }
68
69
    /**
70
     * @param null $member
71
     *
72
     * @return bool|int
73
     */
74 1
    public function canDelete($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
75
    {
76 1
        return Permission::check('Operation_DELETE', 'any', $member);
77
    }
78
79 1
    /**
80
     * @param null $member
81
     *
82
     * @return bool
83
     */
84
    public function canView($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
85
    {
86
        return true;
87
    }
88
}
89