/** * @return void * @param $currentActions array of actionPackets * @desc merges those actions packets that have the same action */ function composeActions($currentActions) { $mergedActionPacketList = array(); //Made a copy for breaking down $comparisonList = $currentActions; while (sizeof($comparisonList) != 0) { //We still have action packets to process //Save the comparison action packet $comparsionObject = $comparisonList[0]; //Remove the action packet we are going to compare. $comparisonList = arrays::array_chop($comparisonList, 0); //Find matches of Action packet and list of action Packets $matches = planComparison::getAllMatchingActions($comparisonList, $comparsionObject); //Update the new array with those that did not match the action packet $comparisonList = $matches['array']; //Merge a list of actionPackets and a actionPacket $mergedActionPacket = planComparison::merge($matches['actions'], $comparsionObject); //Collect result array_push($mergedActionPacketList, $mergedActionPacket); } return $mergedActionPacketList; }
function testArrayChop() { $this->sendMessage("test"); $this->assertEqual(arrays::array_chop(array(1, 2, 3), 0), array(2, 3)); }