Ejemplo n.º 1
0
 /**
  * Parse attribute key recursively
  *
  * @param array        $parsedFields Reference to array of parsed fields
  * @param StringObject $key Current key to parse
  */
 private function buildFields(&$parsedFields, StringObject $key)
 {
     if ($key->contains('.')) {
         $parts = $key->explode('.', 2)->val();
         if (!isset($parsedFields[$parts[0]])) {
             $parsedFields[$parts[0]] = [];
         }
         $this->buildFields($parsedFields[$parts[0]], $this->str($parts[1]));
     } else {
         $parsedFields[$key->val()] = '';
     }
 }
Ejemplo n.º 2
0
 private function validateSection(StringObject $section)
 {
     $tmp = $section->explode($this->delimiter);
     if ($tmp->first()->contains('-') || $this->isNumber($tmp->first()->val())) {
         throw new ConfigException(sprintf('Invalid config key "%s"', $section->val()));
     }
 }
Ejemplo n.º 3
0
 /**
  * Set url path.
  *
  * @param StringObject|string $path Url path.
  *
  * @throws UrlObjectException
  * @return $this
  */
 public function setPath($path)
 {
     try {
         $path = new StringObject($path);
     } catch (\Exception $e) {
         throw new UrlObjectException($e->getMessage());
     }
     if ($path != '') {
         $path->trimLeft('/');
         $this->path = '/' . $path->val();
     } else {
         $this->path = $path->val();
     }
     $this->rebuildUrl();
     return $this;
 }
Ejemplo n.º 4
0
 public function testTruncate2()
 {
     $s = new StringObject('A very long word.');
     $s->truncate(10, '...');
     $this->assertSame('A very...', $s->val());
 }