Passed
Push — master ( 879ca4...d0a2dc )
by Robbie
03:13
created

SAMLMemberExtension   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
dl 0
loc 33
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A updateCMSFields() 0 4 1
1
<?php
2
3
namespace SilverStripe\SAML\Extensions;
4
5
use SilverStripe\Forms\FieldList;
6
use SilverStripe\Forms\ReadonlyField;
7
use SilverStripe\ORM\DataExtension;
8
9
/**
10
 * Class SAMLMemberExtension
11
 *
12
 * Adds mappings from IdP claim rules to SilverStripe {@link Member} fields.
13
 *
14
 * @package activedirectory
15
 */
16
class SAMLMemberExtension extends DataExtension
17
{
18
    /**
19
     * @var array
20
     */
21
    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...
22
        // Pointer to the session object held by the IdP
23
        'SAMLSessionIndex' => 'Varchar(255)',
24
        // Unique user identifier, same field is used by LDAPMemberExtension
25
        'GUID' => 'Varchar(50)',
26
    ];
27
28
    /**
29
     * These are used by {@link SAMLController} to map specific IdP claim rules
30
     * to {@link Member} fields. Availability of these claim rules are defined
31
     * on the IdP.
32
     *
33
     * @var array
34
     * @config
35
     */
36
    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...
37
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/givenname' => 'FirstName',
38
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/surname' => 'Surname',
39
        'http://schemas.xmlsoap.org/ws/2005/05/identity/claims/emailaddress' => 'Email'
40
    ];
41
42
    /**
43
     * @param FieldList $fields
44
     */
45
    public function updateCMSFields(FieldList $fields)
46
    {
47
        $fields->replaceField('GUID', ReadonlyField::create('GUID'));
0 ignored issues
show
Bug introduced by
'GUID' of type string is incompatible with the type array expected by parameter $args of SilverStripe\View\ViewableData::create(). ( Ignorable by Annotation )

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

47
        $fields->replaceField('GUID', ReadonlyField::create(/** @scrutinizer ignore-type */ 'GUID'));
Loading history...
48
        $fields->removeFieldFromTab('Root', 'SAMLSessionIndex');
49
    }
50
}
51