get() public method

Get the value stored under key $name if it's set - otherwise return $default.
public get ( string $name, mixed $default = null ) : mixed
$name string The key name for the desired value.
$default mixed (Optional) a default value to return if $name is not set.
return mixed
Example #1
0
 public function testGet()
 {
     $valueHolder = new ValueHolder();
     $this->assertNull($valueHolder->get('key'));
     $this->assertEquals('default', $valueHolder->get('key', 'default'));
     $this->assertNull($valueHolder->get('key'));
 }
Example #2
0
 /**
  * Get the source files as an associative array.
  *
  * @return array
  */
 public function getSourceFiles()
 {
     $sourceFiles = array();
     $ignore = $this->configuration->get('ignore');
     if (is_dir($this->get('source'))) {
         $recursiveIterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($this->get('source')));
         foreach ($recursiveIterator as $file) {
             if (!$ignore || !preg_match($ignore, $file->getPathname())) {
                 $sourceFiles[$file->getFilename()] = $file->getPathname();
             }
         }
     }
     return $sourceFiles;
 }
Example #3
0
 /**
  * Get a single option value for this command, optionally providing a default value
  * for it.
  *
  * @see    \Clinner\ValueHolder::get()
  *
  * @param  string $name    The name of the option.
  * @param  mixed  $default The default value for the option, in case it isn't set.
  *
  * @return mixed
  */
 public function getOption($name, $default = null)
 {
     return $this->_options->get($name, $default);
 }