diff --git a/src/bootstrap/requires.php b/src/bootstrap/requires.php index b0a0620..857dd38 100644 --- a/src/bootstrap/requires.php +++ b/src/bootstrap/requires.php @@ -61,7 +61,7 @@ final class requires { * @return string */ public static function filter_dir_path(string $dir): string { - return preg_replace('/[^a-z0-9_\\/]+/i', "", $dir); + return preg_replace('/[^-a-z0-9_\\/]+/i', "", $dir); } private static function get_PHP_Version_for_file(string $file): string|bool { diff --git a/src/classes/services/twilio_setup.php b/src/classes/services/twilio_setup.php new file mode 100644 index 0000000..64c23a0 --- /dev/null +++ b/src/classes/services/twilio_setup.php @@ -0,0 +1,38 @@ + + * @copyright (c) 2025, Robert Strutts + * @license MIT + */ +namespace CodeHydrater\services; + +use CodeHydrater\bootstrap\registry as Reg; + +final class twilio_setup { + const VENDOR = CodeHydrater_PROJECT . 'vendor/twilio/sdk/src/Twilio/'; + + public static function init_sms($sid, $token) { + if (! Reg::get('loader')->is_loaded('Twilio')) { + Reg::get('loader')->add_namespace('Twilio', self::VENDOR); + } + + if ($sid === false) { + throw new \Exception("Twilio SID not defined"); + } + if ($token === false) { + throw new \Exception("Twilio TOKEN not defined"); + } + return new \Twilio\Rest\Client($sid, $token); + } + + public static function init_voice() { + if (! Reg::get('loader')->is_loaded('Twilio')) { + Reg::get('loader')->add_namespace('Twilio', self::VENDOR); + return new \Twilio\TwiML\VoiceResponse(); + } + } + +} \ No newline at end of file