PluginProbe
The Innovative Form Builder – IvyForms / 1.5
The Innovative Form Builder – IvyForms v1.5
1.5.1 1.5 1.4.1 1.4 trunk 0.1.2 0.2 0.2.1 0.3 0.3.1 0.4 0.5 0.6 0.6.1 0.6.1-backup 0.6.1.1 0.7 0.8 0.8.1 0.8.2 0.9 0.9.1 1.0 1.1 1.1.1 All 27 releases
ivyforms / backend / src / Factory / Security / CaptchaProviderRegistry.php

CaptchaProviderRegistry.php in The Innovative Form Builder – IvyForms 1.5, at backend/src/Factory/Security/CaptchaProviderRegistry.php

98 lines 2.2 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 /**
4 * @copyright © Melograno Venture Studio. All rights reserved.
5 * @licence See COPYING.md for license details.
6 */
7
8 namespace IvyForms\Factory\Security;
9
10 use IvyForms\Services\Security\Common\CaptchaServiceInterface;
11
12 /**
13 * Registry for managing CAPTCHA service instances
14 *
15 * Handles caching and lifecycle management of CAPTCHA service instances
16 * to avoid unnecessary object creation and improve performance.
17 *
18 * @package IvyForms\Factory\Security
19 */
20 class CaptchaProviderRegistry
21 {
22 /**
23 * @var array<string, CaptchaServiceInterface>
24 */
25 private array $services = [];
26
27 /**
28 * Register a service instance for a provider
29 *
30 * @param string $provider The provider identifier
31 * @param CaptchaServiceInterface $service The service instance
32 */
33 public function register(string $provider, CaptchaServiceInterface $service): void
34 {
35 $this->services[$provider] = $service;
36 }
37
38 /**
39 * Get a registered service instance
40 *
41 * @param string $provider The provider identifier
42 * @return CaptchaServiceInterface|null
43 */
44 public function get(string $provider): ?CaptchaServiceInterface
45 {
46 return $this->services[$provider] ?? null;
47 }
48
49 /**
50 * Check if a provider is registered
51 *
52 * @param string $provider The provider identifier
53 * @return bool
54 */
55 public function has(string $provider): bool
56 {
57 return isset($this->services[$provider]);
58 }
59
60 /**
61 * Remove a provider from the registry
62 *
63 * @param string $provider The provider identifier
64 */
65 public function remove(string $provider): void
66 {
67 unset($this->services[$provider]);
68 }
69
70 /**
71 * Clear all registered services
72 */
73 public function clear(): void
74 {
75 $this->services = [];
76 }
77
78 /**
79 * Get all registered provider names
80 *
81 * @return array<string>
82 */
83 public function getRegisteredProviders(): array
84 {
85 return array_keys($this->services);
86 }
87
88 /**
89 * Get count of registered services
90 *
91 * @return int
92 */
93 public function count(): int
94 {
95 return count($this->services);
96 }
97 }
98