Completed
Push — develop ( 63a64b...1c0683 )
by
unknown
06:54 queued 04:03
created

RaListingService::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
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\Authorization\Value\InstitutionAuthorizationContextInterface;
24
use Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing;
25
use Surfnet\StepupMiddleware\ApiBundle\Identity\Query\RaListingQuery;
26
use Surfnet\StepupMiddleware\ApiBundle\Identity\Repository\RaListingRepository;
27
use Surfnet\StepupMiddleware\ApiBundle\Identity\Value\RegistrationAuthorityCredentials;
28
29
class RaListingService extends AbstractSearchService
30
{
31
    /**
32
     * @var RaListingRepository
33
     */
34
    private $raListingRepository;
35
36
    public function __construct(RaListingRepository $raListingRepository)
37
    {
38
        $this->raListingRepository = $raListingRepository;
39
    }
40
41
    /**
42
     * @param IdentityId $identityId
43
     * @param Institution $raInstitution
44
     * @param InstitutionAuthorizationContextInterface $authorizationContext
45
     * @return null|\Surfnet\StepupMiddleware\ApiBundle\Identity\Entity\RaListing
46
     */
47
    public function findByIdentityIdAndRaInstitutionWithContext(
48
        IdentityId $identityId,
49
        Institution $raInstitution,
50
        InstitutionAuthorizationContextInterface $authorizationContext
51
    ) {
52
        return $this->raListingRepository->findByIdentityIdAndRaInstitutionWithContext($identityId, $raInstitution, $authorizationContext);
53
    }
54
55
    /**
56
     * @param RaListingQuery $query
57
     * @return \Pagerfanta\Pagerfanta
58
     */
59
    public function search(RaListingQuery $query)
60
    {
61
        $doctrineQuery = $this->raListingRepository->createSearchQuery($query);
62
63
        $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
64
65
        return $paginator;
66
    }
67
68
    /**
69
     * @param Institution $institution
70
     * @return RegistrationAuthorityCredentials[]
71
     */
72
    public function listRegistrationAuthoritiesFor(Institution $institution)
73
    {
74
        $raListings = $this->raListingRepository->listRasFor($institution);
75
76
        return $raListings
77
            ->map(function (RaListing $raListing) {
78
                return RegistrationAuthorityCredentials::fromRaListing($raListing);
0 ignored issues
show
Bug introduced by
The method fromRaListing() does not exist on Surfnet\StepupMiddleware...ionAuthorityCredentials. Did you maybe mean fromRaListings()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
79
            })
80
            ->toArray();
81
    }
82
}
83