Completed
Pull Request — develop (#236)
by
unknown
04:24 queued 02:09
created

InstitutionAuthorizationProjector   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A applyUseRaOptionChangedEvent() 0 7 1
A applyUseRaaOptionChangedEvent() 0 7 1
A applySelectRaaOptionChangedEvent() 0 7 1
1
<?php
2
3
/**
4
 * Copyright 2018 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\SelectRaaOptionChangedEvent;
23
use Surfnet\Stepup\Configuration\Event\UseRaaOptionChangedEvent;
24
use Surfnet\Stepup\Configuration\Event\UseRaOptionChangedEvent;
25
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository;
26
27
final class InstitutionAuthorizationProjector extends Projector
28
{
29
    /**
30
     * @var InstitutionAuthorizationRepository
31
     */
32
    private $institutionAuthorizationRepository;
33
34
    public function __construct(
35
        InstitutionAuthorizationRepository $institutionAuthorizationRepository
36
    ) {
37
        $this->institutionAuthorizationRepository = $institutionAuthorizationRepository;
38
    }
39
40
    public function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
41
    {
42
        $this->institutionAuthorizationRepository->saveInstitutionOption(
43
            $event->institution,
44
            $event->useRaOption
45
        );
46
    }
47
    public function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
48
    {
49
        $this->institutionAuthorizationRepository->saveInstitutionOption(
50
            $event->institution,
51
            $event->useRaaOption
52
        );
53
    }
54
    public function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
55
    {
56
        $this->institutionAuthorizationRepository->saveInstitutionOption(
57
            $event->institution,
58
            $event->selectRaaOption
59
        );
60
    }
61
}
62