You are here

class StringHelper in RESTful 7.2

Class StringHelper.

@package Drupal\restful\Util

Hierarchy

Expanded class hierarchy of StringHelper

1 file declares its use of StringHelper
Request.php in src/Http/Request.php
Contains \Drupal\restful\Http\Request

File

src/Util/StringHelper.php, line 15
Contains \Drupal\restful\Util\String.

Namespace

Drupal\restful\Util
View source
class StringHelper {

  /**
   * Turns a string into camel case.
   *
   * @param string $input
   *   The input string.
   *
   * @return string
   *   The camelized string.
   */
  public static function camelize($input) {
    $input = preg_replace('/[-_]/', ' ', $input);
    $input = ucwords($input);
    $parts = explode(' ', $input);
    return implode('', $parts);
  }

  /**
   * Remove the string prefix from the token value.
   *
   * @param string $prefix
   *   The prefix to remove.
   * @param string $haystack
   *   The string to remove the prefix from.
   *
   * @return string
   *   The prefixless string. NULL if the prefix is not found.
   */
  public static function removePrefix($prefix, $haystack) {
    $position = strpos($haystack, $prefix);
    if ($position === FALSE) {
      return NULL;
    }
    return substr($haystack, $position + strlen($prefix));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
StringHelper::camelize public static function Turns a string into camel case.
StringHelper::removePrefix public static function Remove the string prefix from the token value.