Ejemplo n.º 1
0
 public function testDefaultValue()
 {
     $array = array();
     ArrayHelper::defaultValue($array, 'key', 'default');
     $this->assertEquals('default', ArrayHelper::getValue($array, 'key'));
     ArrayHelper::defaultValue($array, 'key', 'value');
     $this->assertEquals('default', ArrayHelper::getValue($array, 'key'));
     $object = new \stdClass();
     ArrayHelper::defaultValue($object, 'key', 'default');
     $this->assertEquals('default', ArrayHelper::getValue($object, 'key'));
     ArrayHelper::defaultValue($object, 'key', 'value');
     $this->assertEquals('default', ArrayHelper::getValue($object, 'key'));
 }
Ejemplo n.º 2
0
 /**
  * @param array $items
  * @param array $options
  *
  * @return string
  */
 public static function pager(array $items, array $options = [])
 {
     // todo: clean up this method (if possible).
     $options['item'] = function ($item) {
         ArrayHelper::defaultValue($item, 'itemOptions', []);
         static::addCssClassWithCondition($item['itemOptions'], 'previous', ArrayHelper::popValue($item, 'previous'));
         static::addCssClassWithCondition($item['itemOptions'], 'next', ArrayHelper::popValue($item, 'next'));
         return static::menuItem($item);
     };
     static::addCssClass($options, 'pager');
     return static::ul($items, $options);
 }