PluginProbe
Blocks – Reusable Content, Shortcodes & Site Variables / trunk
Blocks – Reusable Content, Shortcodes & Site Variables vtrunk
26.09.03.15 26.08.31.21 26.08.22.20 26.08.22.22 26.08.22.17 26.08.22.13 26.08.21.19 26.08.07.23 26.07.19.14 26.07.13.21 26.07.13.17 26.07.12.13 026.07.07.21 026.07.05.18 026.06.26.20 026.06.26.21 026.06.08.20 026.05.13.14 026.04.29.10 trunk 026.02.22.22 026.03.16.23 026.04.23.13
blocks / src / LiveChat / ProviderIdValidator.php

ProviderIdValidator.php in Blocks – Reusable Content, Shortcodes & Site Variables trunk, at src/LiveChat/ProviderIdValidator.php

24 lines 604 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 declare(strict_types=1);
4
5 namespace RenzoJohnson\Blocks\LiveChat;
6
7 \defined( 'ABSPATH' ) || exit;
8
9 final class ProviderIdValidator {
10
11 public static function is_valid( string $provider, string $identifier ): bool {
12 if ( '' === $identifier ) {
13 return false;
14 }
15
16 return match ( $provider ) {
17 'olark' => 1 === \preg_match( '/^\d{4}-\d{3}-\d{2}-\d{4}$/D', $identifier ),
18 'crisp' => 1 === \preg_match( '/^[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}$/Di', $identifier ),
19 'tawk' => 1 === \preg_match( '/^[a-f0-9]{24}\/[a-z0-9_-]{1,64}$/Di', $identifier ),
20 default => false,
21 };
22 }
23 }
24