Browse Source

Add/Correct some nsUtils comments

nsITobin 4 months ago
parent
commit
b96ad71842
1 changed files with 17 additions and 11 deletions
  1. 17 11
      base/src/nsUtilsCore.php

+ 17 - 11
base/src/nsUtilsCore.php

@@ -132,18 +132,22 @@ class nsRuntime {
   * Application Init
   *********************************************************************************************************************/
   public static function init() {
+    // Gaurd against being init'd again
     if (nsRuntime::$sInitialized) {
       return nsRuntime::$sInitialized;
     }
 
     // ------------------------------------------------------------------------------------------------------------------
 
+    // Explode the path
     $path = nsUtils::ExplodePath(nsRuntime::SuperGlobal('get', 'path', kSlash));
 
+    // Handle localhost
     if (defined('kLocalDomain') && SAPI_IS_CLI) {
       $localDomain = kLocalDomain;
     }
 
+    // Set a configuration array
     $config = array(
       'app' => array(
         'component'   => nsRuntime::SuperGlobal('get', 'component', 'site'),
@@ -177,6 +181,7 @@ class nsRuntime {
       ),
     );
 
+    // Handle debug mode
     if (defined('kDebugDomain') && !SAPI_IS_CLI) {
       $config['app']['debug'] = (nsRuntime::SuperGlobal('server', 'SERVER_NAME', 'localhost') != constant('kDebugDomain') ?? kEmptyString) ?
                                 file_exists(nsUtils::BuildPath(kRootPath, '.debugMode')) :
@@ -185,6 +190,7 @@ class nsRuntime {
 
     // ------------------------------------------------------------------------------------------------------------------
 
+    // Set runtime configuration to our inital configuration
     nsRuntime::$sRuntimeConfiguration = new \Adbar\Dot($config);
 
     // ------------------------------------------------------------------------------------------------------------------
@@ -689,14 +695,14 @@ class nsRuntime {
   }
 
   /********************************************************************************************************************
-  * Get the registry property and return it
+  * Get the debyg property and return it
   ********************************************************************************************************************/
   public static function Debug() {
     return (nsRuntime::$sRuntimeConfiguration) ? nsRuntime::GetConfig('app.debug') : kDebugMode;
   }
 
   /********************************************************************************************************************
-  * Get the registry property and return it
+  * Get the registry and return it
   ********************************************************************************************************************/
   public static function GetStore() {
     return nsRuntime::$sRuntimeConfiguration->get();
@@ -777,7 +783,7 @@ class nsUtils {
   // ------------------------------------------------------------------------------------------------------------------
 
   /**********************************************************************************************************************
-  * nsUtils::Subst
+  * Do "Filter Subtsitution" of a string
   ***********************************************************************************************************************/
   public static function Subst(string $aString, array $aSubsts, bool $aRegEx = false) {
     $rv = $aString;
@@ -791,7 +797,7 @@ class nsUtils {
   } 
     
   /**********************************************************************************************************************
-  * nsUtils::SubstEx
+  * Do advanced "Filter Substitution" of a string
   ***********************************************************************************************************************/
   public static function SubstEx(string $aString, ...$aSubsts) {
     $keyPrefix = kLeftBrace;
@@ -813,7 +819,7 @@ class nsUtils {
   }
 
   /**********************************************************************************************************************
-  * nsUtils::Contains
+  * Universal Contains substring/array_key/array_value
   ***********************************************************************************************************************/
   public static function Contains(string|array $aHaystack, string|array $aNeedle, int $aPos = kZero) {
     $rv = false;
@@ -848,7 +854,7 @@ class nsUtils {
   }
 
   /**********************************************************************************************************************
-  * nsUtils::ExplodeStr
+  * Explode a string into an array
   ***********************************************************************************************************************/
   public static function ExplodeStr(string $aSeparator, string $aString) {
     return (!str_contains($aString, $aSeparator)) ? [$aString] :
@@ -856,14 +862,14 @@ class nsUtils {
   }
 
   /**********************************************************************************************************************
-  * gExplodePath
+  * Explode a path into an array
   ***********************************************************************************************************************/
   public static function ExplodePath(string $aPath) {
     return ($aPath == kSlash) ? ['root'] : nsUtils::ExplodeStr(kSlash, $aPath);
   }
 
   /**********************************************************************************************************************
-  * nsUtils::BuildPath
+  * Build a path from arguments
   ***********************************************************************************************************************/
   public static function BuildPath(...$aParts) {
     $parts = kEmptyArray;
@@ -899,7 +905,7 @@ class nsUtils {
   }
 
   /**********************************************************************************************************************
-  * nsUtils::StripStr
+  * Strip the string of the supplied substring
   ***********************************************************************************************************************/
   public static function StripStr (string $aStr, string $aStrip = kEmptyString) {
     return str_replace($aStrip, kEmptyString, $aStr);
@@ -1243,7 +1249,7 @@ class nsConsole {
   }
 
   /********************************************************************************************************************
-  * Gets or sets the "default" content type so we don't have to output the header ourselves in most cases.
+  * Send HTTP Headers
   ********************************************************************************************************************/
   public static function SendHeaders() {
     $responseCode = nsRuntime::GetConfig('console.output.responseCode', 200);
@@ -1258,7 +1264,7 @@ class nsConsole {
   }
 
   /********************************************************************************************************************
-  * Gets or sets the "default" content type so we don't have to output the header ourselves in most cases.
+  * Gets or sets the status code
   ********************************************************************************************************************/
   public static function HttpStatusCode(?string $aStatusCode = null) {
     if (!$aStatusCode) {