Browse Source

documentation

euromark 12 years ago
parent
commit
a9198f3a9c
2 changed files with 23 additions and 5 deletions
  1. 20 2
      Lib/Utility/Utility.php
  2. 3 3
      Test/Case/Lib/Utility/UtilityTest.php

+ 20 - 2
Lib/Utility/Utility.php

@@ -404,7 +404,12 @@ class Utility {
 	}
 
 	/**
-	 * Flattens an array.
+	 * Force-flattens an array.
+	 *
+	 * Careful with this method. It can lose information.
+	 * The keys will not be changed, thus possibly overwrite each other.
+	 *
+	 * //TODO: check if it can be replace by Hash::flatten() or Utility::flatten().
 	 *
 	 * @param array $array to flatten
 	 * @param boolean $perserveKeys
@@ -429,8 +434,15 @@ class Utility {
 	}
 
 	/**
-	 * Flatten an array and preserve the keys
+	 * Force-flattens an array and preserves the keys.
+	 *
+	 * Careful with this method. It can lose information.
+	 * The keys will not be changed, thus possibly overwrite each other.
+	 *
+	 * //TODO: check if it can be replace by Hash::flatten() or Utility::flatten().
 	 *
+	 * @param array $a
+	 * @param array $f
 	 * @return array
 	 */
 	protected static function _arrayFlatten($a, $f = array()) {
@@ -467,6 +479,7 @@ class Utility {
 	 * Returns microtime as float value
 	 * (to be subtracted right away)
 	 *
+	 * @param int $precision
 	 * @return float
 	 */
 	public static function microtime($precision = 8) {
@@ -481,6 +494,8 @@ class Utility {
 	}
 
 	/**
+	 * @param int $precision
+	 * @param boolean $restartClock
 	 * @return float
 	 */
 	public static function returnElapsedTime($precision = 8, $restartClock = false) {
@@ -495,6 +510,9 @@ class Utility {
 	 * Returns microtime as float value
 	 * (to be subtracted right away)
 	 *
+	 * @param int $start
+	 * @param int $end
+	 * @param int $precision
 	 * @return float
 	 */
 	public static function calcElapsedTime($start, $end, $precision = 8) {

+ 3 - 3
Test/Case/Lib/Utility/UtilityTest.php

@@ -317,7 +317,7 @@ class UtilityTest extends MyCakeTestCase {
 	}
 
 	/**
-	 * UtilityTest::testArrayFlatten()
+	 * Test that deeper nested values overwrite higher ones.
 	 *
 	 * @covers Utility::arrayFlatten
 	 * @return void
@@ -325,15 +325,15 @@ class UtilityTest extends MyCakeTestCase {
 	public function testArrayFlatten() {
 		$array = array(
 			'a' => 1,
-			'b' => array('c' => array('d' => array('f' => 'g', 'h' => true))),
+			'b' => array('h' => false, 'c' => array('d' => array('f' => 'g', 'h' => true))),
 			'k' => 'm',
 		);
 		$res = Utility::arrayFlatten($array);
 
 		$expected = array(
 			'a' => 1,
-			'f' => 'g',
 			'h' => true,
+			'f' => 'g',
 			'k' => 'm',
 		);
 		$this->assertSame($expected, $res);