PluginProbe
authLdap / 3.1.4
authLdap v3.1.4
trunk 2.5.3 2.5.3-RC3 2.5.4 2.5.6 2.5.7 2.5.8 2.5.9 2.6.0 2.6.1 2.6.2 2.6.3 2.6.4 3.0.0 3.0.1 3.0.2 3.0.3 3.0.4 3.1.0 3.1.1 3.1.2 3.1.3 3.1.4
authldap / src / Options.php

Options.php in authLdap 3.1.4, at src/Options.php

92 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * Copyright Andreas Heigl <andreas@heigl.org>
5 *
6 * Licensed under the MIT-license. For details see the included file LICENSE.md
7 */
8
9 declare(strict_types=1);
10
11 namespace Org_Heigl\AuthLdap;
12
13 use Org_Heigl\AuthLdap\Exception\UnknownOption;
14
15 use function array_key_exists;
16
17 class Options
18 {
19 public const ENABLED = 'Enabled';
20 public const CACHE_PW = 'CachePW';
21 public const URI = 'URI';
22 public const URI_SEPARATOR = 'URISeparator';
23 public const FILTER = 'Filter';
24 public const NAME_ATTR = 'NameAttr';
25 public const SEC_NAME = 'SecName';
26 public const UID_ATTR = 'UidAttr';
27 public const MAIL_ATTR = 'MailAttr';
28 public const WEB_ATTR = 'WebAttr';
29 public const GROUPS = 'Groups';
30 public const DEBUG = 'Debug';
31 public const GROUP_ATTR = 'GroupAttr';
32 public const GROUP_FILTER = 'GroupFilter';
33 public const DEFAULT_ROLE = 'DefaultRole';
34 public const GROUP_ENABLE = 'GroupEnable';
35 public const GROUP_OVER_USER = 'GroupOverUser';
36 public const VERSION = 'Version';
37 public const DO_NOT_OVERWRITE_NON_LDAP_USERS = 'DoNotOverwriteNonLdapUsers';
38
39 private array $settings = [
40 'Enabled' => false,
41 'CachePW' => false,
42 'URI' => '',
43 'URISeparator' => ' ',
44 'Filter' => '', // '(uid=%s)'
45 'NameAttr' => '', // 'name'
46 'SecName' => '',
47 'UidAttr' => '', // 'uid'
48 'MailAttr' => '', // 'mail'
49 'WebAttr' => '',
50 'Groups' => [],
51 'Debug' => false,
52 'GroupAttr' => '', // 'gidNumber'
53 'GroupFilter' => '', // '(&(objectClass=posixGroup)(memberUid=%s))'
54 'DefaultRole' => '',
55 'GroupEnable' => true,
56 'GroupOverUser' => true,
57 'Version' => 1,
58 'DoNotOverwriteNonLdapUsers' => false,
59 ];
60
61 public function get(string $key)
62 {
63 if (! array_key_exists($key, $this->settings)) {
64 throw UnknownOption::withKey($key);
65 }
66
67 return $this->settings[$key];
68 }
69
70 public function has(string $key): bool
71 {
72 return array_key_exists($key, $this->settings);
73 }
74
75 /**
76 * @param mixed $value
77 */
78 public function set(string $key, $value): void
79 {
80 if (! array_key_exists($key, $this->settings)) {
81 throw UnknownOption::withKey($key);
82 }
83
84 $this->settings[$key] = $value;
85 }
86
87 public function toArray(): array
88 {
89 return $this->settings;
90 }
91 }
92