InstitutionConfigurationRepository::removeFor()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
rs 10
c 1
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
/**
0 ignored issues
show
Coding Style introduced by
The file-level docblock must follow the opening PHP tag in the file header
Loading history...
6
 * Copyright 2022 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
 */
20
21
namespace Surfnet\StepupMiddleware\GatewayBundle\Repository;
22
23
use Doctrine\ORM\EntityRepository;
24
use Surfnet\StepupMiddleware\GatewayBundle\Entity\InstitutionConfiguration;
25
26
/**
27
 * @extends EntityRepository<InstitutionConfiguration>
28
 */
29
class InstitutionConfigurationRepository extends EntityRepository
30
{
31
    public function findByInstitution(string $institution): ?InstitutionConfiguration
32
    {
33
        return $this->findOneBy(['institution' => $institution]);
34
    }
35
36
    public function save(InstitutionConfiguration $institutionConfiguration): void
37
    {
38
        $entityManager = $this->getEntityManager();
39
        $entityManager->persist($institutionConfiguration);
40
        $entityManager->flush();
41
    }
42
43
    public function removeFor(string $institution): void
44
    {
45
        $this->createQueryBuilder('ic')
46
            ->delete()
47
            ->where('id.institution = :institution')
48
            ->setParameter('institution', $institution)
49
            ->getQuery()
50
            ->execute();
51
    }
52
}
53