Completed
Push — feature/use-authn-request-acs-... ( b0d5b4...6c793d )
by
unknown
03:10
created

ConnectedServiceProviders::getConfigurationOf()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 12
rs 9.4285
cc 3
eloc 6
nc 3
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\StepupGateway\SamlStepupProviderBundle\Provider;
20
21
use Surfnet\StepupGateway\GatewayBundle\Service\SamlEntityService;
22
use Surfnet\StepupGateway\SamlStepupProviderBundle\Exception\InvalidArgumentException;
23
use Surfnet\StepupGateway\SamlStepupProviderBundle\Exception\UnknownProviderException;
24
25
final class ConnectedServiceProviders
26
{
27
    private $connected;
28
29
    /**
30
     * @var \Surfnet\StepupGateway\GatewayBundle\Service\SamlEntityService
31
     */
32
    private $samlEntityService;
33
34
    public function __construct(SamlEntityService $samlEntityService, array $connectedServiceProviders)
35
    {
36
        $this->samlEntityService = $samlEntityService;
37
38
        foreach ($connectedServiceProviders as $serviceProvider) {
39
            $this->connectServiceProvider($serviceProvider);
40
        }
41
    }
42
43
    /**
44
     * @param string $serviceProvider
45
     * @return bool
46
     */
47
    public function isConnected($serviceProvider)
48
    {
49
        if (!is_string($serviceProvider)) {
50
            throw InvalidArgumentException::invalidType('string', 'serviceProvider', $serviceProvider);
51
        }
52
53
        return in_array($serviceProvider, $this->connected);
54
    }
55
56
    /**
57
     * @param string $serviceProvider
58
     */
59
    private function connectServiceProvider($serviceProvider)
60
    {
61
        if (!is_string($serviceProvider)) {
62
            throw InvalidArgumentException::invalidType('string', 'serviceProvider', $serviceProvider);
63
        }
64
65
        $this->connected[] = $serviceProvider;
66
    }
67
}
68