CreatorOnlyCanEditExtension   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3
Metric Value
wmc 4
lcom 1
cbo 3
dl 0
loc 18
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A canEdit() 0 12 4
1
<?php
2
3
class CreatorOnlyCanEditExtension extends Extension
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
4
{
5
    /*
6
    Only allow editing when the current user is the same as the creator for each of cycling route, cycling exploration and cycling short
7
    */
8
    public function canEdit($member = null)
0 ignored issues
show
Unused Code introduced by
The parameter $member 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...
9
    {
10
        //return in_array($this->owner->ClassName, array('RideFolder','Ride','CyclingShort','CyclingRoute','CyclingExploration'));
11
        $caneditasowner = true;
12
        if (in_array($this->owner->ClassName, array('CyclingShort', 'CyclingRoute', 'CyclingExploration'))) {
13
            if ($this->owner->CreatorID != Member::currentUserID()) {
14
                $caneditasowner = false;
15
            }
16
        }
17
18
        return (Permission::check('ADMIN')) || $caneditasowner;
19
    }
20
}
21