Exemplo n.º 1
0
 /**
  * Set config value
  * @param string|array $key
  * @param mixed $value
  * @return $this
  */
 public function set($key, $value = null)
 {
     if (is_array($key)) {
         foreach ($key as $k => $v) {
             $this->set($k, $v);
         }
         return $this;
     }
     \Exedra\Support\DotArray::set($this->storage, $key, $value);
     return $this;
 }
Exemplo n.º 2
0
 public function testDelete()
 {
     DotArray::set($this->storage, 'foo.bar', 'baz');
     DotArray::set($this->storage, 'foo.baz', 'qux');
     DotArray::set($this->storage, 'foo.tuq', 'nux');
     $this->assertEquals($this->storage['foo']['bar'], 'baz');
     DotArray::delete($this->storage, 'foo.bar');
     $this->assertTrue(!isset($this->storage['foo']['bar']));
     $this->assertEquals($this->storage['foo']['baz'], 'qux');
     DotArray::delete($this->storage, 'foo');
     $this->assertTrue(!DotArray::has($this->storage, 'foo.tuq.nux'));
 }
Exemplo n.º 3
0
 /**
  * Set a session by the given key.
  * @param string key
  * @param mixed value
  * @return \Exedra\Session\Session
  */
 public function set($key, $value)
 {
     \Exedra\Support\DotArray::set($this->getStorage(), $key, $value);
     return $this;
 }
Exemplo n.º 4
0
 /**
  * Parse docblock to key-value array
  * @param string text
  * @return array
  */
 protected function parseDocBlock($text)
 {
     // http://www.murraypicton.com/archive/building-a-phpdoc-parser-in-php
     if (preg_match('#^/\\*\\*(.*)\\*/#s', $text, $comment) === false) {
         return array();
     }
     if (!isset($comment[1])) {
         return array();
     }
     $comment = trim($comment[1]);
     // http://www.murraypicton.com/archive/building-a-phpdoc-parser-in-php
     if (preg_match_all('#^\\s*\\*(.*)#m', $comment, $lines) === false) {
         return array();
     }
     $data = array();
     $lastParam = null;
     foreach ($lines[1] as $line) {
         $line = trim($line);
         if ($line[0] !== '@') {
             if ($lastParam) {
                 $lastParam .= '\\n' . $line;
             }
             continue;
         }
         @(list($key, $value) = explode(' ', $line, 2));
         $key = substr($key, 1);
         \Exedra\Support\DotArray::set($data, $key, trim($value));
         $lastParam =& \Exedra\Support\DotArray::getReference($data, $key);
     }
     foreach ($data as $key => $value) {
         if (!isset($this->commandParamAliases[$key])) {
             continue;
         }
         unset($data[$key]);
         $data[$this->commandParamAliases[$key]] = $value;
     }
     return $data;
 }
Exemplo n.º 5
0
 /**
  * Update the given param
  * @param string key
  * @param mixed value
  * @return this
  */
 public function setParam($key, $value = null)
 {
     \Exedra\Support\DotArray::set($this->params, $key, $value);
 }