|
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\Stepup\Identity\Entity; |
|
20
|
|
|
|
|
21
|
|
|
use Exception; |
|
22
|
|
|
use Surfnet\Stepup\DateTime\DateTime; |
|
23
|
|
|
use Surfnet\Stepup\Exception\InvalidArgumentException; |
|
24
|
|
|
use Surfnet\Stepup\Identity\Value\EmailVerificationWindow; |
|
|
|
|
|
|
25
|
|
|
use Surfnet\Stepup\Identity\Value\Locale; |
|
|
|
|
|
|
26
|
|
|
use Surfnet\Stepup\Identity\Value\TimeFrame; |
|
|
|
|
|
|
27
|
|
|
|
|
28
|
|
|
/** |
|
29
|
|
|
* Entity that contains the User Defined Settings that are relevant to the domain |
|
30
|
|
|
*/ |
|
31
|
|
|
final class ConfigurableSettings |
|
32
|
|
|
{ |
|
33
|
|
|
/** |
|
34
|
|
|
* @var Locale[] |
|
35
|
|
|
*/ |
|
36
|
|
|
private readonly array $locales; |
|
37
|
|
|
|
|
38
|
|
|
/** |
|
39
|
|
|
* @param Locale[] $locales |
|
40
|
|
|
*/ |
|
41
|
|
|
private function __construct( |
|
42
|
|
|
private readonly TimeFrame $emailVerificationTimeFrame, |
|
43
|
|
|
array $locales, |
|
44
|
|
|
) { |
|
45
|
|
|
foreach ($locales as $index => $locale) { |
|
46
|
|
|
if (!$locale instanceof Locale) { |
|
47
|
|
|
throw InvalidArgumentException::invalidType( |
|
48
|
|
|
Locale::class, |
|
49
|
|
|
sprintf('locales[%s]', $index), |
|
50
|
|
|
$locale, |
|
51
|
|
|
); |
|
52
|
|
|
} |
|
53
|
|
|
} |
|
54
|
|
|
$this->locales = $locales; |
|
|
|
|
|
|
55
|
|
|
} |
|
56
|
|
|
|
|
57
|
|
|
/** |
|
58
|
|
|
* @param int $emailVerificationTimeFrame positive integer |
|
59
|
|
|
* @param string[] $locales |
|
60
|
|
|
* @return ConfigurableSettings |
|
61
|
|
|
* @throws Exception |
|
62
|
|
|
* @throws Exception |
|
63
|
|
|
*/ |
|
64
|
|
|
public static function create(int $emailVerificationTimeFrame, array $locales): self |
|
65
|
|
|
{ |
|
66
|
|
|
return new self( |
|
67
|
|
|
TimeFrame::ofSeconds($emailVerificationTimeFrame), |
|
68
|
|
|
array_map( |
|
69
|
|
|
fn($locale): Locale => new Locale($locale), |
|
70
|
|
|
$locales, |
|
71
|
|
|
), |
|
72
|
|
|
); |
|
73
|
|
|
} |
|
74
|
|
|
|
|
75
|
|
|
/** |
|
76
|
|
|
* @return EmailVerificationWindow |
|
77
|
|
|
*/ |
|
78
|
|
|
public function createNewEmailVerificationWindow(): EmailVerificationWindow |
|
79
|
|
|
{ |
|
80
|
|
|
return EmailVerificationWindow::createFromTimeFrameStartingAt( |
|
81
|
|
|
$this->emailVerificationTimeFrame, |
|
82
|
|
|
DateTime::now(), |
|
83
|
|
|
); |
|
84
|
|
|
} |
|
85
|
|
|
|
|
86
|
|
|
public function isSupportedLocale(Locale $locale): bool |
|
87
|
|
|
{ |
|
88
|
|
|
return array_reduce( |
|
89
|
|
|
$this->locales, |
|
90
|
|
|
fn($supported, Locale $supportedLocale): bool => $supported || $supportedLocale->equals($locale), |
|
91
|
|
|
false, |
|
92
|
|
|
); |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths