Completed
Pull Request — develop (#235)
by
unknown
05:32 queued 02:49
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 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\SelectRaaOptionChangedEvent;
23
use Surfnet\Stepup\Configuration\Event\UseRaaOptionChangedEvent;
24
use Surfnet\Stepup\Configuration\Event\UseRaOptionChangedEvent;
25
use Surfnet\Stepup\Configuration\Value\InstitutionOption;
26
use Surfnet\StepupMiddleware\ApiBundle\Configuration\Repository\InstitutionAuthorizationRepository;
27
28
final class InstitutionAuthorizationProjector extends Projector
29
{
30
    /**
31
     * @var InstitutionAuthorizationRepository
32
     */
33
    private $institutionAuthorizationRepository;
34
35
    public function __construct(
36
        InstitutionAuthorizationRepository $institutionAuthorizationRepository
37
    ) {
38
        $this->institutionAuthorizationRepository = $institutionAuthorizationRepository;
39
    }
40
41
    public function applyUseRaOptionChangedEvent(UseRaOptionChangedEvent $event)
42
    {
43
        $this->institutionAuthorizationRepository->saveInstitutionOption(
44
            $event->institution,
45
            $event->useRaOption
46
        );
47
    }
48
    public function applyUseRaaOptionChangedEvent(UseRaaOptionChangedEvent $event)
49
    {
50
        $this->institutionAuthorizationRepository->saveInstitutionOption(
51
            $event->institution,
52
            $event->useRaaOption
53
        );
54
    }
55
    public function applySelectRaaOptionChangedEvent(SelectRaaOptionChangedEvent $event)
56
    {
57
        $this->institutionAuthorizationRepository->saveInstitutionOption(
58
            $event->institution,
59
            $event->selectRaaOption
60
        );
61
    }
62
}
63