Completed
Pull Request — master (#30)
by Jason
02:29
created

OperationManual::providePermissions()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 6
Ratio 100 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 4
c 1
b 0
f 0
nc 1
nop 0
dl 6
loc 6
ccs 2
cts 2
cp 1
crap 1
rs 9.4285
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';
0 ignored issues
show
introduced by
The private property $singular_name is not used, and could be removed.
Loading history...
14
15
    /**
16
     * @var string
17
     */
18
    private static $plural_name = 'OperationManuals';
0 ignored issues
show
introduced by
The private property $plural_name is not used, and could be removed.
Loading history...
19
20
    /**
21
     * @var string
22
     */
23
    private static $table_name = 'OperationManual';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
24
25
    /**
26
     * @return FieldList
0 ignored issues
show
Bug introduced by
The type Dynamic\ProductCatalog\Docs\FieldList was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
27
     */
28 1
    public function getCMSFields()
29
    {
30 1
        $fields = parent::getCMSFields();
31
32 1
        $fields->dataFieldByName('Download')->setFolderName('Uploads/Products/OperationManuals');
33
34 1
        return $fields;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $fields returns the type SilverStripe\Forms\FieldList which is incompatible with the documented return type Dynamic\ProductCatalog\Docs\FieldList.
Loading history...
35
    }
36
37
    /**
38
     * @return array
39
     */
40 1
    public function providePermissions()
41
    {
42
        return array(
43 1
            'Operation_EDIT' => 'Edit Operation Manuals',
44
            'Operation_DELETE' => 'Delete Operation Manuals',
45
            'Operation_CREATE' => 'Create Operation Manuals',
46
        );
47
    }
48
49
    /**
50
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
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
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
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. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

64
    public function canEdit($member = null, /** @scrutinizer ignore-unused */ $context = [])

This check looks for 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
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
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. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

74
    public function canDelete($member = null, /** @scrutinizer ignore-unused */ $context = [])

This check looks for 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
    /**
80
     * @param null $member
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $member is correct as it would always require null to be passed?
Loading history...
81
     *
82
     * @return bool
83
     */
84 45
    public function canView($member = null, $context = [])
0 ignored issues
show
Unused Code introduced by
The parameter $context is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

84
    public function canView($member = null, /** @scrutinizer ignore-unused */ $context = [])

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

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