code: public static function camelCaseToUnderscore($string)
      {
          return Preg::replaceCallback(
              '/(^|[a-z0-9])([A-Z])/',
              static function (array $matches) {
                  return strtolower('' !== $matches[1] ? $matches[1].'_'.$matches[2] : $matches[2]);
              },
              $string
          );
      }
docs: Converts a camel cased string to an snake cased string.
  
  @param string $string
  
  @return string