Completed
Pull Request — develop (#39)
by A.
03:11 queued 50s
created

GlobalViewParameters::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 19
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 4
Bugs 0 Features 3
Metric Value
c 4
b 0
f 3
dl 0
loc 19
rs 9.4286
cc 1
eloc 16
nc 1
nop 6
1
<?php
2
3
/**
4
 * Copyright 2015 SURFnet B.V.
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 OpenConext\ProfileBundle\Service;
20
21
use InvalidArgumentException;
22
use OpenConext\Profile\Assert;
23
use Symfony\Component\Translation\DataCollectorTranslator;
24
use Symfony\Component\Translation\TranslatorInterface;
25
26
final class GlobalViewParameters
27
{
28
    /**
29
     * @var TranslatorInterface
30
     */
31
    private $translator;
32
33
    /**
34
     * @var array
35
     */
36
    private $helpUrls;
37
38
    /**
39
     * @var array
40
     */
41
    private $platformUrls;
42
43
    /**
44
     * @var array
45
     */
46
    private $termsOfServiceUrls;
47
48
    /**
49
     * @var array
50
     */
51
    private $profileExplanationImageUrls;
52
53
    /**
54
     * @param TranslatorInterface $translator
55
     * @param array $locales
56
     * @param array $helpUrls
57
     * @param array $platformUrls
58
     * @param array $termsOfServiceUrls
59
     * @param array $profileExplanationImageUrls
60
     */
61
    public function __construct(
62
        TranslatorInterface $translator,
63
        array $locales,
64
        array $helpUrls,
65
        array $platformUrls,
66
        array $termsOfServiceUrls,
67
        array $profileExplanationImageUrls
68
    ) {
69
        Assert::keysAre($helpUrls, $locales);
70
        Assert::keysAre($platformUrls, $locales);
71
        Assert::keysAre($termsOfServiceUrls, $locales);
72
        Assert::keysAre($profileExplanationImageUrls, $locales);
73
74
        $this->translator                  = $translator;
75
        $this->helpUrls                    = $helpUrls;
76
        $this->platformUrls                = $platformUrls;
77
        $this->termsOfServiceUrls          = $termsOfServiceUrls;
78
        $this->profileExplanationImageUrls = $profileExplanationImageUrls;
79
    }
80
81
    /**
82
     * @return string
83
     */
84
    public function getHelpUrl()
85
    {
86
        return $this->helpUrls[$this->translator->getLocale()];
87
    }
88
89
    /**
90
     * @return string
91
     */
92
    public function getPlatformUrl()
93
    {
94
        return $this->platformUrls[$this->translator->getLocale()];
95
    }
96
97
    /**
98
     * @return string
99
     */
100
    public function getTermsOfServiceUrl()
101
    {
102
        return $this->termsOfServiceUrls[$this->translator->getLocale()];
103
    }
104
105
    /**
106
     * @return string
107
     */
108
    public function getProfileExplanationImage()
109
    {
110
        return $this->profileExplanationImageUrls[$this->translator->getLocale()];
111
    }
112
}
113