/** * Pivots an array to create a reverse lookup of an array of scalars, arrays or objects. * * @param array $source The source array. * @param string $key Where the elements of the source array are objects or arrays, the key to pivot on. * * @return array An array of arrays pivoted either on the value of the keys, or an individual key of an object or array. * * @since 11.3 * @deprecated 4.0 Use Joomla\Utilities\ArrayHelper::pivot instead */ public static function pivot($source, $key = null) { $result = array(); if (is_array($source)) { $result = ArrayHelper::pivot($source, $key); } else { JLog::add('This method is typehinted to be an array in \\Joomla\\Utilities\\ArrayHelper::pivot.', JLog::WARNING, 'deprecated'); } return $result; }
/** * Tests the ArrayHelper::pivot method. * * @param array $source The source array. * @param string $key Where the elements of the source array are objects or arrays, the key to pivot on. * @param array $expected The expected result. * * @return void * * @dataProvider seedTestPivot * @covers Joomla\Utilities\ArrayHelper::pivot * @since 1.0 */ public function testPivot($source, $key, $expected) { $this->assertThat(ArrayHelper::pivot($source, $key), $this->equalTo($expected)); }