Completed
Push — bugfix/fix-auth-filter ( 1eb831...fd8948 )
by
unknown
02:22
created

RaListingService::search()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
/**
4
 * Copyright 2014 SURFnet bv
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\Identity\Service;
20
21
use Surfnet\Stepup\Identity\Value\IdentityId;
22
use Surfnet\Stepup\Identity\Value\Institution;
23
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing;
24
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaListingQuery;
25
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository;
26
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials;
27
28
class RaListingService extends AbstractSearchService
29
{
30
    /**
31
     * @var RaListingRepository
32
     */
33
    private $raListingRepository;
34
35
    public function __construct(RaListingRepository $raListingRepository)
36
    {
37
        $this->raListingRepository = $raListingRepository;
38
    }
39
40
    /**
41
     * @param IdentityId $identityId
42
     * @param Institution $raInstitution
43
     * @return null|\Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing
0 ignored issues
show
Documentation introduced by
Should the return type not be object|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
44
     */
45
    public function findByIdentityIdAndRaInstitution(IdentityId $identityId, Institution $raInstitution)
46
    {
47
        return $this->raListingRepository->findByIdentityIdAndRaInstitution($identityId, $raInstitution);
48
    }
49
50
    /**
51
     * @param RaListingQuery $query
52
     * @return \Pagerfanta\Pagerfanta
53
     */
54
    public function search(RaListingQuery $query)
55
    {
56
        $doctrineQuery = $this->raListingRepository->createSearchQuery($query);
57
58
        $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
59
60
        return $paginator;
61
    }
62
63
    /**
64
     * @param Institution $institution
65
     * @return RegistrationAuthorityCredentials[]
66
     */
67
    public function listRegistrationAuthoritiesFor(Institution $institution)
68
    {
69
        $raListings = $this->raListingRepository->listRasFor($institution);
70
71
        return $raListings
72
            ->map(function (RaListing $raListing) {
73
                return RegistrationAuthorityCredentials::fromRaListing($raListing);
74
            })
75
            ->toArray();
76
    }
77
}
78