public static function convertToClass($mixed) { if (is_object($mixed)) { $mixed = get_class($mixed); } else { \UString::doNotStartWith($mixed, '\\'); } return $mixed; }
public function initialize() { parent::initialize(); $this->router = new \Stack\Router(); if (isset($_SERVER['REQUEST_URI'])) { $uri = \UString::substrBefore($_SERVER['REQUEST_URI'], '?'); $uri = rawurldecode($uri); \UString::doNotStartWith($uri, $this->baseUri); \UString::doStartWith($uri, '/'); $this->router->setUri($uri); } }
public function byName($name, $prefix = NULL) { $class = ['Stack\\View']; \UString::doNotStartWith($prefix, ['\\', '_']); \UString::doNotEndWith($prefix, ['\\', '_']); if (!empty($prefix)) { $class[] = $prefix; } \UString::doNotStartWith($name, ['\\', '_']); \UString::doNotEndWith($name, ['\\', '_']); if (!empty($name)) { $class[] = $name; } $class = implode('\\', $class); return new $class(); }
public function fromString($string) { $return = new $this(); if (\UString::isStartWith($string, ['http://', 'https://', '//'])) { \UString::doSubstrAfter($string, '//'); $return->host = \UString::substrBefore($string, ['/', ':']); \UString::doNotStartWith($string, $return->host); $return->port = 80; } if (\UString::isStartWith($string, ':')) { \UString::doNotStartWith($string, ':'); $return->port = intval(\UString::doSubstrAfter($string, '/')); } \UString::doNotEndWith($string, '/'); \UString::doStartWith($string, '/'); $return->uri = $string; return $return; }
protected function doFormatExtensionNamespace(&$namespace) { $namespace = str_replace(DIRECTORY_SEPARATOR, '\\', $namespace); \UString::doNotStartWith($namespace, '\\'); \UString::doNotEndWith($namespace, '\\'); }
public function test_do_not_start_with__multiple_match() { $assertion = 'https://http://www.example.com'; \UString::doNotStartWith($assertion, array('file://', 'https://', 'http://')); $this->assertEquals('www.example.com', $assertion); }
public static function stripSpecialChar($string, $chars = '-_a-zA-Z0-9', $replace = '-') { $string = preg_replace('/[^' . $chars . ']/s', $replace, $string); if (!empty($replace)) { $string = preg_replace('/[' . $replace . ']+/s', $replace, $string); \UString::doNotStartWith($string, $replace); \UString::doNotEndWith($string, $replace); } return $string; }