WhitelistService   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A contains() 0 7 2
1
<?php
2
3
/**
4
 * Copyright 2015 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\Service;
20
21
use Surfnet\StepupGateway\GatewayBundle\Entity\WhitelistEntryRepository;
22
use Surfnet\StepupGateway\GatewayBundle\Exception\InvalidArgumentException;
23
24
class WhitelistService
25
{
26
    /**
27
     * @var WhitelistEntryRepository
28
     */
29
    private $whitelistEntryRepository;
30
31
    public function __construct(WhitelistEntryRepository $whitelistEntryRepository)
32
    {
33
        $this->whitelistEntryRepository = $whitelistEntryRepository;
34
    }
35
36
    /**
37
     * @param string $institution
38
     * @return bool
39
     */
40
    public function contains($institution)
41
    {
42
        if (!is_string($institution)) {
0 ignored issues
show
introduced by
The condition is_string($institution) is always true.
Loading history...
43
            throw InvalidArgumentException::invalidType('string', 'institution', $institution);
44
        }
45
46
        return $this->whitelistEntryRepository->hasEntryFor($institution);
47
    }
48
}
49