Example #1
0
 public function __construct()
 {
     // Initialize project namespace
     $projectName = \UObject::getClassName($this);
     \UString::doNotEndWith($projectName, 'Test');
     $this->projectNamespace .= $projectName;
 }
Example #2
0
 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();
 }
Example #3
0
 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;
 }
Example #4
0
 public function setBaseUri($baseUri)
 {
     \UString::doStartWith($baseUri, '/');
     \UString::doNotEndWith($baseUri, '/');
     $this->baseUri = $baseUri;
     return $this;
 }
Example #5
0
 protected function doFormatExtensionNamespace(&$namespace)
 {
     $namespace = str_replace(DIRECTORY_SEPARATOR, '\\', $namespace);
     \UString::doNotStartWith($namespace, '\\');
     \UString::doNotEndWith($namespace, '\\');
 }
Example #6
0
 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);
 }
Example #7
0
 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;
 }