Esempio n. 1
0
/**
 * @param     $var
 * @param int $depth
 *
 * @return mixed
 */
function og_dump($var = NULL, $depth = 12)
{
    \Tracy\Debugger::$maxDepth = $depth;
    $args = func_get_args();
    Util::array_forget(func_num_args() - 1, $args);
    $dumper = defined('PHPUNIT_TESTS__') ? 'Tracy\\Dumper::toTerminal' : 'Tracy\\Debugger::dump';
    array_map($dumper, $args);
    return $var;
}
Esempio n. 2
0
 public function test03()
 {
     ### array_forget(&$array, $keys)
     # forget by single key
     $worker = $this->source_array;
     Util::array_forget('Candy', $worker);
     $this->assertEquals(['Apples' => 'One', 'Beets' => 2], $worker);
     # forget by dot path
     $worker = $this->source_array;
     Util::array_forget('Candy.start', $worker);
     $this->assertEquals(['Apples' => 'One', 'Beets' => 2, 'Candy' => ['end' => 'then']], $worker);
     ### array_extract_list($find_key, $array)
     $records = ['George' => ['age' => 26, 'gender' => 'Male'], 'Lois' => ['age' => 32, 'gender' => 'Female']];
     $this->assertEquals([26, 32], Util::extract_column('age', $records));
     ### (simple) array_make_compare_list(array $array)
     $worker = Util::assoc_from_str('name:Laura, access:Administrator');
     $this->assertEquals(['name=`Laura`', 'access=`Administrator`'], Util::make_compare($worker));
     # empty returns null
     $this->assertNull(Util::make_compare([]));
     # list returns null on invalid array (must be associative)
     $this->assertNull(Util::make_compare(['bad']));
 }