Commits

Norbert Nemetvolgyi  committed de89113

refactored code

  • Participants
  • Parent commits 8b44d7a

Comments (0)

Files changed (1)

File src/ActivityID.php

 <?php
 class ActivityID
 {
+    /**
+     * @param $activityID
+     * @return string
+     */
     public static function toString($activityID=0)
     {
-        $hotSpotID = (($activityID - 1) % 3) + 1;
-        return "L01M0" . strval(floor((int)$activityID / 3) + 1) . "0" . strval($hotSpotID);
+        $hotSpotStr = self::getHotSpotStr($activityID);
+        $topicStr = self::getTopicStr($activityID);
+
+        return "L01" . $topicStr . $hotSpotStr;
+    }
+
+    /**
+     * @param $activityID
+     * @return string
+     */
+    private static function getTopicStr($activityID)
+    {
+        return "M0" . strval(self::getTopicID($activityID));
+    }
+
+    /**
+     * @param $activityID
+     * @return float
+     */
+    private static function getTopicID($activityID)
+    {
+        return floor((int)$activityID / 3) + 1;
+    }
+
+    /**
+     * @param $activityID
+     * @return string
+     */
+    private static function getHotSpotStr($activityID)
+    {
+        return "0" . strval(self::getHotSpotID($activityID));
+    }
+
+    /**
+     * @param $activityID
+     * @return int
+     */
+    private static function getHotSpotID($activityID)
+    {
+        return (($activityID - 1) % 3) + 1;
     }
 }