ConsoleKit\Utils::dashized PHP Метод

dashized() публичный статический Метод

Returns a camelCased string into a dash-cased string
public static dashized ( string $string ) : string
$string string
Результат string
    public static function dashized($string)
    {
        return strtolower(preg_replace('/(?<=[a-z])([A-Z])/', '-$1', $string));
    }

Usage Example

Пример #1
0
 /**
  * Creates an Help object from a class subclassing Command
  *
  * @param string $name
  * @param string $subCommand
  * @return Help
  */
 public static function fromCommandClass($name, $subCommand = null)
 {
     $prefix = 'execute';
     $class = new ReflectionClass($name);
     if ($subCommand) {
         $method = $prefix . ucfirst(Utils::camelize($subCommand));
         if (!$class->hasMethod($method)) {
             throw new ConsoleException("Sub command '{$subCommand}' of '{$name}' does not exist");
         }
         return new Help($class->getMethod($method)->getDocComment());
     }
     $help = new Help($class->getDocComment());
     foreach ($class->getMethods() as $method) {
         if (strlen($method->getName()) > strlen($prefix) && substr($method->getName(), 0, strlen($prefix)) === $prefix) {
             $help->subCommands[] = Utils::dashized(substr($method->getName(), strlen($prefix)));
         }
     }
     return $help;
 }
All Usage Examples Of ConsoleKit\Utils::dashized