DoctrineSamlEntityRepository   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 32
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getIdentityProvider() 0 9 1
A getServiceProvider() 0 9 1
1
<?php
2
3
/**
4
 * Copyright 2016 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\StepupGateway\GatewayBundle\Entity;
20
21
use Doctrine\Common\Collections\ArrayCollection;
22
use Doctrine\ORM\EntityRepository;
23
use Doctrine\ORM\Query\Parameter;
24
25
class DoctrineSamlEntityRepository extends EntityRepository implements SamlEntityRepository
26
{
27
    /**
28
     * @param $entityId
29
     * @return null|SamlEntity
30
     * @throws \Doctrine\ORM\NonUniqueResultException
31
     */
32
    public function getIdentityProvider($entityId)
33
    {
34
        return $this
35
            ->createQueryBuilder('s')
36
            ->where('s.type = :entityType')
37
            ->andWhere('s.entityId = :entityId')
38
            ->setParameters(new ArrayCollection([new Parameter('entityType', SamlEntity::TYPE_IDP), new Parameter('entityId', $entityId)]))
39
            ->getQuery()
40
            ->getOneOrNullResult();
41
    }
42
43
    /**
44
     * @param $entityId
45
     * @return null|SamlEntity
46
     * @throws \Doctrine\ORM\NonUniqueResultException
47
     */
48
    public function getServiceProvider($entityId)
49
    {
50
        return $this
51
            ->createQueryBuilder('s')
52
            ->where('s.type = :entityType')
53
            ->andWhere('s.entityId = :entityId')
54
            ->setParameters(new ArrayCollection([new Parameter('entityType', SamlEntity::TYPE_SP), new Parameter('entityId', $entityId)]))
55
            ->getQuery()
56
            ->getOneOrNullResult();
57
    }
58
}
59