Completed
Push — feature/fix-ra-listing-endpoin... ( 8ce24d )
by
unknown
02:42
created

RaListingService   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A findByIdentityIdAndRaInstitutionWithContext() 0 4 1
A search() 0 8 1
A listRegistrationAuthoritiesFor() 0 10 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(IdentityId $identityId, Institution $raInstitution, InstitutionAuthorizationContextInterface $authorizationContext)
48
    {
49
        return $this->raListingRepository->findByIdentityIdAndRaInstitutionWithContext($identityId, $raInstitution, $authorizationContext);
50
    }
51
52
    /**
53
     * @param RaListingQuery $query
54
     * @return \Pagerfanta\Pagerfanta
55
     */
56
    public function search(RaListingQuery $query)
57
    {
58
        $doctrineQuery = $this->raListingRepository->createSearchQuery($query);
59
60
        $paginator = $this->createPaginatorFrom($doctrineQuery, $query);
61
62
        return $paginator;
63
    }
64
65
    /**
66
     * @param Institution $institution
67
     * @return RegistrationAuthorityCredentials[]
68
     */
69
    public function listRegistrationAuthoritiesFor(Institution $institution)
70
    {
71
        $raListings = $this->raListingRepository->listRasFor($institution);
72
73
        return $raListings
74
            ->map(function (RaListing $raListing) {
75
                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...
76
            })
77
            ->toArray();
78
    }
79
}
80