]> git.mxchange.org Git - hub.git/blobdiff - application/hub/main/handler/protocol/class_BaseProtocolHandler.php
Continued refacturing:
[hub.git] / application / hub / main / handler / protocol / class_BaseProtocolHandler.php
index c2421c1dd0fee41014a0da7250a97329e4cb10ab..902a4cdcd5f74464ca8c3f3ca81dec985d3ed883 100644 (file)
@@ -32,6 +32,27 @@ class BaseProtocolHandler extends BaseHandler {
                // Call parent constructor
                parent::__construct($className);
        }
+
+       /**
+        * Validates given UNL very basicly by given regular expression. You
+        * normally don't need/want to overwrite this method as this is a very basic
+        * validation only based on a regex.
+        *
+        * @param       $unl            Universal Node Locator to validate
+        * @param       $regex          Regular expression to use for validation without slashes
+        * @return      $isValid        Whether the UNL is valid
+        */
+       protected final function isValidUniversalNodeLocator ($unl, $regex) {
+               // Debug message
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: unl=' . $unl . ',regex=' . $regex . ' - CALLED!');
+
+               // Very basic regex check
+               $isValid = (preg_match('/^' . $regex . '$/', $unl) === 1);
+
+               // Return result
+               //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('[' . __METHOD__ . ':' . __LINE__ . ']: isValid=' . intval($isValid) . ' - EXIT!');
+               return $isValid;
+       }
 }
 
 // [EOF]