RaService::listRasWithoutRaas()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 10
nc 3
nop 1
dl 0
loc 17
rs 9.9332
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types = 1);
4
5
/**
6
 * Copyright 2014 SURFnet bv
7
 *
8
 * Licensed under the Apache License, Version 2.0 (the "License");
9
 * you may not use this file except in compliance with the License.
10
 * You may obtain a copy of the License at
11
 *
12
 *     http://www.apache.org/licenses/LICENSE-2.0
13
 *
14
 * Unless required by applicable law or agreed to in writing, software
15
 * distributed under the License is distributed on an "AS IS" BASIS,
16
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
 * See the License for the specific language governing permissions and
18
 * limitations under the License.
19
 */
0 ignored issues
show
Coding Style introduced by
PHP version not specified
Loading history...
Coding Style introduced by
Missing @category tag in file comment
Loading history...
Coding Style introduced by
Missing @package tag in file comment
Loading history...
Coding Style introduced by
Missing @author tag in file comment
Loading history...
Coding Style introduced by
Missing @license tag in file comment
Loading history...
Coding Style introduced by
Missing @link tag in file comment
Loading history...
20
21
namespace Surfnet\StepupSelfService\SelfServiceBundle\Service;
22
23
use Surfnet\StepupMiddlewareClientBundle\Identity\Command\SendSecondFactorRegistrationEmailCommand;
24
use Surfnet\StepupMiddlewareClientBundle\Identity\Dto\RegistrationAuthorityCredentialsCollection;
25
use Surfnet\StepupMiddlewareClientBundle\Identity\Service\RaService as ApiRaService;
26
27
readonly class RaService
0 ignored issues
show
Coding Style introduced by
Missing doc comment for class RaService
Loading history...
28
{
29
    public function __construct(
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function __construct()
Loading history...
30
        private ApiRaService   $api,
31
        private CommandService $commandService,
32
    ) {
33
    }
34
35
    public function listRas(string $institution): RegistrationAuthorityCredentialsCollection
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function listRas()
Loading history...
36
    {
37
        return $this->api->listRas($institution);
38
    }
39
40
    public function listRasWithoutRaas(string $institution): RegistrationAuthorityCredentialsCollection
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function listRasWithoutRaas()
Loading history...
41
    {
42
        $allRas = $this->api->listRas($institution);
43
44
        $rasWithoutRaas = [];
45
        foreach ($allRas->getElements() as $ra) {
46
            if (!$ra->isRaa) {
47
                $rasWithoutRaas[] = $ra;
48
            }
49
        }
50
51
        // All RAs and RAAs are fetched, so this can safely be returned (no pagination is used here)
52
        return new RegistrationAuthorityCredentialsCollection(
53
            $rasWithoutRaas,
54
            count($rasWithoutRaas),
55
            $allRas->getItemsPerPage(),
56
            $allRas->getCurrentPage()
57
        );
58
    }
59
60
    public function sendRegistrationMailMessage(string $identityId, string $secondFactorId): void
0 ignored issues
show
Coding Style introduced by
Missing doc comment for function sendRegistrationMailMessage()
Loading history...
61
    {
62
        $command = new SendSecondFactorRegistrationEmailCommand();
63
        $command->identityId = $identityId;
64
        $command->secondFactorId = $secondFactorId;
65
        $this->commandService->execute($command);
66
    }
67
}
68