Ejemplo n.º 1
0
 public static function convertToClass($mixed)
 {
     if (is_object($mixed)) {
         $mixed = get_class($mixed);
     } else {
         \UString::doNotStartWith($mixed, '\\');
     }
     return $mixed;
 }
Ejemplo n.º 2
0
 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);
     }
 }
Ejemplo n.º 3
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();
 }
Ejemplo n.º 4
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;
 }
Ejemplo n.º 5
0
 protected function doFormatExtensionNamespace(&$namespace)
 {
     $namespace = str_replace(DIRECTORY_SEPARATOR, '\\', $namespace);
     \UString::doNotStartWith($namespace, '\\');
     \UString::doNotEndWith($namespace, '\\');
 }
Ejemplo n.º 6
0
 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);
 }
Ejemplo n.º 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;
 }