public function __construct() { // Initialize project namespace $projectName = \UObject::getClassName($this); \UString::doNotEndWith($projectName, 'Test'); $this->projectNamespace .= $projectName; }
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; }
public function setBaseUri($baseUri) { \UString::doStartWith($baseUri, '/'); \UString::doNotEndWith($baseUri, '/'); $this->baseUri = $baseUri; return $this; }
protected function doFormatExtensionNamespace(&$namespace) { $namespace = str_replace(DIRECTORY_SEPARATOR, '\\', $namespace); \UString::doNotStartWith($namespace, '\\'); \UString::doNotEndWith($namespace, '\\'); }
public function test_do_not_end_with__multiple_match() { $assertion = 'http://www.example.com/\\/'; \UString::doNotEndWith($assertion, array('\\', '/')); $this->assertEquals('http://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; }