Example #1
0
 public function testEach()
 {
     $dump = array('foo' => array('bar' => 'baz', 'quz' => array('tux' => 'nux')), 'juz' => 'tuq', 'dax' => array('nut' => 'jar'));
     $new = array();
     DotArray::each($dump, function ($key, $value) use(&$new) {
         $new[] = $key;
     });
     $this->assertEquals(array('foo.bar', 'foo.quz.tux', 'juz', 'dax.nut'), $new);
 }
Example #2
0
 /**
  * Destroy session, or only the given key.
  * @param string key
  * @return \Exedra\Session\Session
  */
 public function destroy($key = null)
 {
     \Exedra\Support\DotArray::delete($this->storage, $key);
     return $this;
 }
Example #3
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;
 }
Example #4
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);
 }
Example #5
0
 /**
  * Unset config through array offset
  * @param string $key
  */
 public function offsetUnset($key)
 {
     \Exedra\Support\DotArray::delete($this->storage, $key);
 }