get() public static method

Returns the value from $key in $array or $default
public static get ( array $array, string $key, mixed $default = null ) : mixed
$array array
$key string
$default mixed
return mixed
示例#1
0
 public function testGet()
 {
     $data = array('foo' => 'bar');
     $this->assertEquals('bar', Utils::get($data, 'foo'));
     $this->assertNull(Utils::get($data, 'unknown'));
     $this->assertEquals('default', Utils::get($data, 'unknown', 'default'));
 }
 /**
  * Execute command
  * 
  * @param array $args
  * @param array $options
  */
 public function execute(array $args, array $options = array())
 {
     if (empty($args)) {
         $this->showUsage();
         $this->showCommands();
     } else {
         $this->showHelp($args[0], Utils::get($args, 1));
     }
 }
示例#3
0
 /**
  * Execute command
  * 
  * @param array $args
  * @param array $options
  */
 public function execute(array $args, array $options = array())
 {
     if (!empty($options['version'])) {
         return $this->showVersion();
     }
     if (empty($args)) {
         $this->writeln("DBVC - Database version control\n");
         $this->showUsage();
         $this->showOptions();
         $this->showCommands();
     } else {
         $this->showHelp($args[0], Utils::get($args, 1));
     }
 }
示例#4
0
 public function execute(array $args, array $options = array())
 {
     if (empty($args)) {
         $formater = new ConsoleKit\TextFormater(array('quote' => ' * '));
         $this->writeln('Available commands:', ConsoleKit\Colors::BLACK | ConsoleKit\Colors::BOLD);
         foreach ($this->console->getCommands() as $name => $fqdn) {
             if ($fqdn !== __CLASS__) {
                 $this->writeln($formater->format($name));
             }
         }
         $this->writeln("Use 'clamp help command' for more info");
     } else {
         $commandFQDN = $this->console->getCommand($args[0]);
         $help = ConsoleKit\Help::fromFQDN($commandFQDN, ConsoleKit\Utils::get($args, 1));
         $this->writeln($help);
     }
 }
示例#5
0
 public function execute(array $args, array $options = array())
 {
     $this->context(array('fgcolor' => Utils::get($options, 'color')), function ($c) use($args) {
         $c->writeln(sprintf('hello %s!', $args[0]));
     });
 }