1 | <?php |
||
21 | class ProviderHelper |
||
22 | { |
||
23 | /** |
||
24 | * @param $provider |
||
25 | * @return string |
||
26 | */ |
||
27 | public static function displayName($provider): string |
||
39 | |||
40 | /** |
||
41 | * @param AbstractProvider $provider |
||
42 | * @param array $properties |
||
43 | * @return array |
||
44 | */ |
||
45 | public static function getProtectedProperties( |
||
46 | AbstractProvider $provider, |
||
47 | array $properties |
||
48 | ): array { |
||
49 | $reflection = new ReflectionClass($provider); |
||
50 | |||
51 | $values = []; |
||
52 | |||
53 | foreach ($properties as $property) { |
||
54 | $values[] = static::getProtectedProperty( |
||
55 | $provider, |
||
56 | $reflection, |
||
57 | $property |
||
58 | ); |
||
59 | } |
||
60 | |||
61 | return $values; |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * @param string $value |
||
66 | * @param bool $checkSettings |
||
67 | * @return string |
||
68 | */ |
||
69 | public static function encryptClientSecret(string $value, bool $checkSettings = true): string |
||
77 | |||
78 | /** |
||
79 | * @param string $value |
||
80 | * @param bool $checkSettings |
||
81 | * @return string |
||
82 | */ |
||
83 | public static function decryptClientSecret(string $value, bool $checkSettings = true): string |
||
108 | |||
109 | |||
110 | /** |
||
111 | * @param AbstractProvider $provider |
||
112 | * @param ReflectionClass $reflectionClass |
||
113 | * @param string $property |
||
114 | * @return mixed |
||
115 | */ |
||
116 | public static function getProtectedProperty( |
||
117 | AbstractProvider $provider, |
||
118 | ReflectionClass $reflectionClass, |
||
119 | string $property |
||
120 | ) { |
||
121 | $reflectionProperty = $reflectionClass->getProperty($property); |
||
122 | $reflectionProperty->setAccessible(true); |
||
123 | return $reflectionProperty->getValue($provider); |
||
124 | } |
||
125 | } |
||
126 |