'created', self::ACTION_CLOSE => 'closed', self::ACTION_UPDATE => 'updated', self::ACTION_ASSIGN => 'assigned', ); return idx($map, $action, "brazenly {$action}'d"); } /** * If a group of transactions contain several actions, select the "strongest" * action. For instance, a close is stronger than an update, because we want * to render "User U closed task T" instead of "User U updated task T" when * a user closes a task. */ public static function selectStrongestAction(array $actions) { static $strengths = array( self::ACTION_UPDATE => 0, self::ACTION_ASSIGN => 1, self::ACTION_CREATE => 2, self::ACTION_CLOSE => 3, ); $strongest = null; $strength = -1; foreach ($actions as $action) { if ($strengths[$action] > $strength) { $strength = $strengths[$action]; $strongest = $action; } } return $strongest; } }