Completed
Pull Request — develop (#220)
by
unknown
08:52 queued 05:21
created

applyNumberOfTokensPerIdentityOptionChangedEvent()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 7
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 4
nc 1
nop 1
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
 */
18
19
namespace Surfnet\StepupMiddleware\ApiBundle\Configuration\Projector;
20
21
use Broadway\ReadModel\Projector;
22
use Surfnet\Stepup\Configuration\Event\InstitutionConfigurationRemovedEvent;
23
use Surfnet\Stepup\Configuration\Event\NewInstitutionConfigurationCreatedEvent;
24
use Surfnet\Stepup\Configuration\Event\NumberOfTokensPerIdentityOptionChangedEvent;
25
use Surfnet\Stepup\Configuration\Event\ShowRaaContactInformationOptionChangedEvent;
26
use Surfnet\Stepup\Configuration\Event\UseRaLocationsOptionChangedEvent;
27
use Surfnet\Stepup\Configuration\Event\VerifyEmailOptionChangedEvent;
28
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Entity\InstitutionConfigurationOptions;
29
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\AllowedSecondFactorRepository;
30
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionConfigurationOptionsRepository;
31
32
final class InstitutionConfigurationOptionsProjector extends Projector
33
{
34
    /**
35
     * @var InstitutionConfigurationOptionsRepository
36
     */
37
    private $institutionConfigurationOptionsRepository;
38
39
    /**
40
     * @var AllowedSecondFactorRepository
41
     */
42
    private $allowedSecondFactorRepository;
43
44
    public function __construct(
45
        InstitutionConfigurationOptionsRepository $institutionConfigurationOptionsRepository,
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptionsRepository exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
46
        AllowedSecondFactorRepository $allowedSecondFactorRepository
47
    ) {
48
        $this->institutionConfigurationOptionsRepository = $institutionConfigurationOptionsRepository;
49
        $this->allowedSecondFactorRepository             = $allowedSecondFactorRepository;
50
    }
51
52
    public function applyNewInstitutionConfigurationCreatedEvent(NewInstitutionConfigurationCreatedEvent $event)
53
    {
54
        $institutionConfigurationOptions = InstitutionConfigurationOptions::create(
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptions exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
55
            $event->institution,
56
            $event->useRaLocationsOption,
57
            $event->showRaaContactInformationOption,
58
            $event->verifyEmailOption,
59
            $event->numberOfTokensPerIdentityOption
60
        );
61
62
        $this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
63
    }
64
65
    public function applyUseRaLocationsOptionChangedEvent(UseRaLocationsOptionChangedEvent $event)
66
    {
67
        $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptions exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
68
        $institutionConfigurationOptions->useRaLocationsOption = $event->useRaLocationsOption;
69
70
        $this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
71
    }
72
73
    public function applyShowRaaContactInformationOptionChangedEvent(ShowRaaContactInformationOptionChangedEvent $event)
74
    {
75
        $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptions exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
76
        $institutionConfigurationOptions->showRaaContactInformationOption = $event->showRaaContactInformationOption;
77
78
        $this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
79
    }
80
81
    public function applyVerifyEmailOptionChangedEvent(VerifyEmailOptionChangedEvent $event)
82
    {
83
        $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptions exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
84
        $institutionConfigurationOptions->verifyEmailOption = $event->verifyEmailOption;
85
86
        $this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
87
    }
88
89
    public function applyNumberOfTokensPerIdentityOptionChangedEvent(NumberOfTokensPerIdentityOptionChangedEvent $event)
90
    {
91
        $institutionConfigurationOptions = $this->institutionConfigurationOptionsRepository->findConfigurationOptionsFor($event->institution);
0 ignored issues
show
Comprehensibility Naming introduced by
The variable name $institutionConfigurationOptions exceeds the maximum configured length of 30.

Very long variable names usually make code harder to read. It is therefore recommended not to make variable names too verbose.

Loading history...
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 142 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
92
        $institutionConfigurationOptions->numberOfTokensPerIdentityOption = $event->numberOfTokensPerIdentityOption;
93
94
        $this->institutionConfigurationOptionsRepository->save($institutionConfigurationOptions);
95
    }
96
97
    public function applyInstitutionConfigurationRemovedEvent(InstitutionConfigurationRemovedEvent $event)
98
    {
99
        $this->institutionConfigurationOptionsRepository->removeConfigurationOptionsFor($event->institution);
100
        $this->allowedSecondFactorRepository->clearAllowedSecondFactorListFor($event->institution);
101
    }
102
}
103