/**
  * Method to test pivotByKey().
  *
  * @param array $data
  * @param array $expected
  *
  * @return void
  *
  * @dataProvider pivotDataProvider
  * @covers       \Windwalker\Helper\ArrayHelper::pivotByKey
  */
 public function testPivotByKey($data, $expected)
 {
     $this->assertEquals($expected, ArrayHelper::pivotByKey($data));
 }
示例#2
0
 /**
  * Parse element data JSON format to array.
  *
  * @param    string $attrs A JSON string.
  *
  * @return   array     Attributes array.
  */
 public function parseAttrs($attrs)
 {
     if (!$attrs) {
         return false;
     }
     $array = (array) json_decode($attrs, true);
     // Rebuild Options
     // ==================================================================
     if (isset($array['options'])) {
         $array['options'] = ArrayHelper::pivotByKey($array['options']);
     }
     return $array;
 }