public function testGetWithDefault() { $this->property->setValue($this->bag, ['foo' => 'bar']); $this->assertEquals('default', $this->bag->get('abc', 'default')); }
/** * Get HTTP header key as originally specified * * @param string $key The case-insensitive header name * @param mixed $default The default value if key does not exist * * @return string */ public function getOriginalKey($key, $default = null) { if ($this->has($key)) { return parent::get($this->normalizeKey($key))['originalKey']; } return $default; }
/** * Retrieve a single derived request attribute. * * Retrieves a single derived request attribute as described in * getAttributes(). If the attribute has not been previously set, returns * the default value as provided. * * This method obviates the need for a hasAttribute() method, as it allows * specifying a default value to return if the attribute is not found. * * @see getAttributes() * @param string $name The attribute name. * @param mixed $default Default value to return if the attribute does not exist. * @return mixed */ public function getAttribute($name, $default = null) { return $this->attributes->get($name, $default); }
/** * Get data value with key * * @param string $key The data key * @param mixed $default The value to return if data key does not exist * @return mixed The data value, or the default value * @api */ public function get($key, $asArray = false) { if ($asArray) { return parent::get($this->normalizeKey($key), array()); } else { return implode(', ', parent::get($this->normalizeKey($key), array())); } }
/** * Get settings for view engine * * @param \Slim\Collection $settings * @return array */ private function getConfig($settings) { $key = 'view'; $defaults = ['template_path' => APP_PATH . '/views', 'twig' => ['cache' => ROOT_PATH . '/tmp/cache/twig', 'debug' => false, 'auto_reload' => true]]; return array_merge($defaults, $settings->get($key, [])); }
/** * Get config for logger * * @param \Slim\Collection $settings * @return array */ private function getConfig($settings) { $key = 'logger'; $defaults = []; return array_merge($defaults, $settings->get($key, [])); }
/** * * @param \Slim\Collection $settings */ protected function getConfig($settings) { return array_merge($this->defaults, $settings->get($this->key, [])); }