deserialize()   B
last analyzed

Complexity

Conditions 7
Paths 64

Size

Total Lines 35
Code Lines 23

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 7
eloc 23
nc 64
nop 1
dl 0
loc 35
rs 8.6186
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Copyright 2016 SURFnet B.V.
5
 *
6
 * Licensed under the Apache License, Version 2.0 (the "License");
7
 * you may not use this file except in compliance with the License.
8
 * You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing, software
13
 * distributed under the License is distributed on an "AS IS" BASIS,
14
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
 * See the License for the specific language governing permissions and
16
 * limitations under the License.
17
 */
0 ignored issues
show
Coding Style introduced by
Missing @link tag in file comment
Loading history...
18
19
namespace Surfnet\Stepup\Configuration\Event;
20
21
use Broadway\Serializer\Serializable as SerializableInterface;
22
use Surfnet\Stepup\Configuration\Value\Institution;
23
use Surfnet\Stepup\Configuration\Value\InstitutionConfigurationId;
24
use Surfnet\Stepup\Configuration\Value\NumberOfTokensPerIdentityOption;
25
use Surfnet\Stepup\Configuration\Value\SelfAssertedTokensOption;
0 ignored issues
show
Bug introduced by
The type Surfnet\Stepup\Configura...elfAssertedTokensOption 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...
26
use Surfnet\Stepup\Configuration\Value\SelfVetOption;
0 ignored issues
show
Bug introduced by
The type Surfnet\Stepup\Configuration\Value\SelfVetOption 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
use Surfnet\Stepup\Configuration\Value\ShowRaaContactInformationOption;
28
use Surfnet\Stepup\Configuration\Value\SsoOn2faOption;
0 ignored issues
show
Bug introduced by
The type Surfnet\Stepup\Configuration\Value\SsoOn2faOption 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...
29
use Surfnet\Stepup\Configuration\Value\SsoRegistrationBypassOption;
0 ignored issues
show
Bug introduced by
The type Surfnet\Stepup\Configura...egistrationBypassOption 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...
30
use Surfnet\Stepup\Configuration\Value\UseRaLocationsOption;
31
use Surfnet\Stepup\Configuration\Value\VerifyEmailOption;
32
33
/**
34
 * When the institution configuration contains a new institution, this event is used
35
 * to record that institution into the institution configuration.
36
 */
0 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @package tag in class comment
Loading history...
Coding Style introduced by
Missing @author tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
37
class NewInstitutionConfigurationCreatedEvent implements SerializableInterface
38
{
39
40
    /**
0 ignored issues
show
Coding Style introduced by
Parameter $institutionConfigurationId should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $institution should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $useRaLocationsOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $showRaaContactInformationOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $verifyEmailOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $numberOfTokensPerIdentityOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $ssoOn2faOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $ssoRegistrationBypassOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $selfVetOption should have a doc-comment as per coding-style.
Loading history...
Coding Style introduced by
Parameter $selfAssertedTokensOption should have a doc-comment as per coding-style.
Loading history...
41
     * @SuppressWarnings(PHPMD.ExcessiveParameterList)
42
     */
43
    public function __construct(
44
        public InstitutionConfigurationId $institutionConfigurationId,
45
        public Institution $institution,
46
        public UseRaLocationsOption $useRaLocationsOption,
47
        public ShowRaaContactInformationOption $showRaaContactInformationOption,
48
        public VerifyEmailOption $verifyEmailOption,
49
        public NumberOfTokensPerIdentityOption $numberOfTokensPerIdentityOption,
50
        public SsoOn2faOption $ssoOn2faOption,
51
        public SsoRegistrationBypassOption $ssoRegistrationBypassOption,
52
        public SelfVetOption $selfVetOption,
53
        public SelfAssertedTokensOption $selfAssertedTokensOption
54
    ) {
55
    }
56
57
    public static function deserialize(array $data): self
58
    {
59
        if (!isset($data['verify_email_option'])) {
60
            $data['verify_email_option'] = true;
61
        }
62
        if (!isset($data['number_of_tokens_per_identity_option'])) {
63
            $data['number_of_tokens_per_identity_option'] = NumberOfTokensPerIdentityOption::DISABLED;
64
        }
65
        // If sso on 2fa option is not yet present, default to false
66
        if (!isset($data['sso_on_2fa_option'])) {
67
            $data['sso_on_2fa_option'] = false;
68
        }
69
        // If GSSP fallback (sso registration bypass) option is not yet present, default to false
70
        if (!isset($data['sso_registration_bypass_option'])) {
71
            $data['sso_registration_bypass_option'] = false;
72
        }
73
        // If self vet option is not yet present, default to false
74
        if (!isset($data['self_vet_option'])) {
75
            $data['self_vet_option'] = false;
76
        }
77
        // If self asserted tokens option is not yet present, default to false
78
        if (!isset($data['self_asserted_tokens_option'])) {
79
            $data['self_asserted_tokens_option'] = false;
80
        }
81
        return new self(
82
            new InstitutionConfigurationId($data['institution_configuration_id']),
83
            new Institution($data['institution']),
84
            new UseRaLocationsOption($data['use_ra_locations_option']),
85
            new ShowRaaContactInformationOption($data['show_raa_contact_information_option']),
86
            new VerifyEmailOption($data['verify_email_option']),
87
            new NumberOfTokensPerIdentityOption($data['number_of_tokens_per_identity_option']),
88
            new SsoOn2faOption($data['sso_on_2fa_option']),
89
            new SsoRegistrationBypassOption($data['sso_registration_bypass_option']),   // Fallback authentication
90
            new SelfVetOption($data['self_vet_option']),
91
            new SelfAssertedTokensOption($data['self_asserted_tokens_option']),
92
        );
93
    }
94
95
    public function serialize(): array
96
    {
97
        return [
98
            'institution_configuration_id' => $this->institutionConfigurationId->getInstitutionConfigurationId(),
99
            'institution' => $this->institution->getInstitution(),
100
            'use_ra_locations_option' => $this->useRaLocationsOption->isEnabled(),
101
            'show_raa_contact_information_option' => $this->showRaaContactInformationOption->isEnabled(),
102
            'verify_email_option' => $this->verifyEmailOption->isEnabled(),
103
            'number_of_tokens_per_identity_option' => $this->numberOfTokensPerIdentityOption->getNumberOfTokensPerIdentity(),
104
            'sso_on_2fa_option' => $this->ssoOn2faOption->isEnabled(),
105
            'sso_registration_bypass_option' => $this->ssoRegistrationBypassOption->isEnabled(),
106
            'self_vet_option' => $this->selfVetOption->isEnabled(),
107
            'self_asserted_tokens_option' => $this->selfAssertedTokensOption->isEnabled(),
108
        ];
109
    }
110
}
111