SAMLMemberExtension   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 35
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 5 1
1
<?php
2
/**
3
 * Class SAMLMemberExtension
4
 *
5
 * Adds mappings from IdP claim rules to SilverStripe {@link Member} fields.
6
 */
7
class SAMLMemberExtension extends DataExtension
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...
8
{
9
    /**
10
     * @var array
11
     */
12
    private static $db = [
0 ignored issues
show
Unused Code introduced by
The property $db 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...
13
        // Pointer to the session object held by the IdP
14
        'SAMLSessionIndex' => 'Varchar(255)',
15
        // Unique user identifier, same field is used by LDAPMemberExtension
16
        'GUID' => 'Varchar(50)',
17
    ];
18
19
    /**
20
     * These are used by {@link SAMLController} to map specific IdP claim rules
21
     * to {@link Member} fields. Availability of these claim rules are defined
22
     * on the IdP.
23
     *
24
     * @var array
25
     * @config
26
     */
27
    private static $claims_field_mappings = [
0 ignored issues
show
Unused Code introduced by
The property $claims_field_mappings 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...
28
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname' => 'FirstName',
29
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname' => 'Surname',
30
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' => 'Email'
31
    ];
32
33
    /**
34
     * @param FieldList $fields
35
     */
36
    public function updateCMSFields(FieldList $fields)
37
    {
38
        $fields->replaceField('GUID', new ReadonlyField('GUID'));
39
        $fields->removeFieldFromTab('Root', 'SAMLSessionIndex');
40
    }
41
}
42