{"action":"created","comment":{"url":"https://api.github.com/repos/CanalTP/MttBundle/pulls/comments/59379198","id":59379198,"diff_hunk":"@@ -30,41 +30,170 @@ public function getFilters()\n \n     public function scheduleFilter($journey, $notes, $notesType = LayoutConfig::NOTES_TYPE_EXPONENT, $calendar = false)\n     {\n-        $value = date('i', $journey->date_time->getTimestamp());\n-        if (count($journey->links) > 0) {\n-            foreach ($journey->links as $link) {\n-                if ($link->type == \"notes\" || $link->type == \"exceptions\") {\n-                    if ($notesType == LayoutConfig::NOTES_TYPE_COLOR) {\n-                        $value = '<span style=\"background-color: ' . $notes[$this->findNoteIndex($link->id, $notes, $calendar)]->color . '\">' . $value . '</span>';\n-                    } else {\n-                        $value .= '<sup>' . $this->footnoteFilter(\n-                            $this->findNoteIndex($link->id, $notes, $calendar)\n-                        ) . '</sup>';\n-                    }\n-                }\n+        $minute = date('i', $journey->date_time->getTimestamp());\n+\n+        if (count($journey->links) < 1) {\n+            return $minute;\n+        }\n+\n+        $colors     = []; $exposents  = [];\n+\n+        foreach ($journey->links as $link) {\n+            if (!$this->linkIsDecorable($link)) {\n+                continue;\n+            }\n+\n+            $noteIndex = $this->findNoteIndex($link->id, $notes, $calendar);\n+\n+            if ($notesType == LayoutConfig::NOTES_TYPE_COLOR) {\n+                $colors[]   = $this->getColor($notes, $noteIndex);\n             }\n+            $exposents[]= $this->getExposent($noteIndex);\n+\n+        }\n+\n+        $colorizedMinute = $this->colorizeMminute($minute, $colors);\n+        return $this->addExposants($colorizedMinute, $exposents, $notesType);\n+    }\n+\n+    /**\n+     * Retrieves color for note index\n+     *\n+     * @param array $notes\n+     * @param Integer $noteIndex\n+     *\n+     * @return string | Null\n+     */\n+    private function getColor(array $notes, $noteIndex)\n+    {\n+        if(!is_integer($noteIndex) || !array_key_exists($noteIndex, $notes)) {\n+            return null;\n         }\n \n-        return $value;\n+        $noteObj = $notes[$noteIndex];\n+        if(!is_object($noteObj) || !property_exists($noteObj, 'color')) {\n+            return null;\n+        }\n+\n+        return $noteObj->color;\n+    }\n+\n+    /**\n+     * Retrieves exposent by note index\n+     *\n+     * @param Integer $noteIndex\n+     * @return Sting | Null\n+     */\n+    private function getExposent($noteIndex)\n+    {\n+        $footNote = $this->getFootNote($noteIndex);\n+        if(empty($footNote)) {\n+           return null;\n+        }\n+\n+        return $footNote;\n     }\n \n-    public function footnoteFilter($index)\n+    /**\n+     * Adds background color to the minute string\n+     *\n+     * @param string $minute\n+     * @param array $colors\n+     * @return String\n+     */\n+    private function colorizeMminute($minute = '', array $colors = [])\n+    {\n+        $cleanedColors = array_filter($colors);\n+\n+        if(empty($cleanedColors)) {\n+            return $minute;\n+        }\n+\n+        return sprintf('<span style=\"background-color: %s\">%s</span>', current($cleanedColors), $minute);\n+\n+    }\n+\n+    /**\n+     * Adds exposents to the minute string if note type isnot color\n+     *\n+     * @param string $minute\n+     * @param array $exposents\n+     * @param type $notesType\n+     *\n+     * @return String\n+     */\n+    private function addExposants($minute = '', array $exposents = [], $notesType)\n+    {\n+        $cleanedExposents = array_filter($exposents);\n+\n+        $exposantsNb = count($cleanedExposents);\n+\n+        if($notesType == LayoutConfig::NOTES_TYPE_COLOR && $exposantsNb < 2) {\n+            return $minute;\n+        }\n+\n+        array_walk($cleanedExposents, function(&$value) {\n+            $value = sprintf('<sup>%s</sup>', $value);\n+        });\n+\n+        return $minute . join('', $cleanedExposents);\n+    }\n+\n+    /**\n+     * Tests that $link is decorable\n+     *\n+     * (type property should be notes or exceptions)\n+     *\n+     * @param object $link\n+     *\n+     * @return boolean\n+     */\n+    private function linkIsDecorable($link)","path":"Twig/ScheduleExtension.php","position":136,"original_position":136,"commit_id":"b02c7824305c727be586f422c4e29d5465f4883a","original_commit_id":"b02c7824305c727be586f422c4e29d5465f4883a","user":{"login":"vchabot","id":715331,"avatar_url":"https://avatars.githubusercontent.com/u/715331?v=3","gravatar_id":"","url":"https://api.github.com/users/vchabot","html_url":"https://github.com/vchabot","followers_url":"https://api.github.com/users/vchabot/followers","following_url":"https://api.github.com/users/vchabot/following{/other_user}","gists_url":"https://api.github.com/users/vchabot/gists{/gist_id}","starred_url":"https://api.github.com/users/vchabot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vchabot/subscriptions","organizations_url":"https://api.github.com/users/vchabot/orgs","repos_url":"https://api.github.com/users/vchabot/repos","events_url":"https://api.github.com/users/vchabot/events{/privacy}","received_events_url":"https://api.github.com/users/vchabot/received_events","type":"User","site_admin":false},"body":"The method name should be `isLinkDecorable`","created_at":"2016-04-12T13:53:59Z","updated_at":"2016-04-12T13:53:59Z","html_url":"https://github.com/CanalTP/MttBundle/pull/102#discussion_r59379198","pull_request_url":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102","_links":{"self":{"href":"https://api.github.com/repos/CanalTP/MttBundle/pulls/comments/59379198"},"html":{"href":"https://github.com/CanalTP/MttBundle/pull/102#discussion_r59379198"},"pull_request":{"href":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102"}}},"pull_request":{"url":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102","id":66148159,"html_url":"https://github.com/CanalTP/MttBundle/pull/102","diff_url":"https://github.com/CanalTP/MttBundle/pull/102.diff","patch_url":"https://github.com/CanalTP/MttBundle/pull/102.patch","issue_url":"https://api.github.com/repos/CanalTP/MttBundle/issues/102","number":102,"state":"open","locked":false,"title":"Feture meth 633 colorize exception note","user":{"login":"tchevily","id":8125361,"avatar_url":"https://avatars.githubusercontent.com/u/8125361?v=3","gravatar_id":"","url":"https://api.github.com/users/tchevily","html_url":"https://github.com/tchevily","followers_url":"https://api.github.com/users/tchevily/followers","following_url":"https://api.github.com/users/tchevily/following{/other_user}","gists_url":"https://api.github.com/users/tchevily/gists{/gist_id}","starred_url":"https://api.github.com/users/tchevily/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchevily/subscriptions","organizations_url":"https://api.github.com/users/tchevily/orgs","repos_url":"https://api.github.com/users/tchevily/repos","events_url":"https://api.github.com/users/tchevily/events{/privacy}","received_events_url":"https://api.github.com/users/tchevily/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-04-12T12:24:55Z","updated_at":"2016-04-12T13:53:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5df1bf46afbac92ce83a653587d7ce10c05baaf6","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102/commits","review_comments_url":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102/comments","review_comment_url":"https://api.github.com/repos/CanalTP/MttBundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/CanalTP/MttBundle/issues/102/comments","statuses_url":"https://api.github.com/repos/CanalTP/MttBundle/statuses/b02c7824305c727be586f422c4e29d5465f4883a","head":{"label":"tchevily:feture_METH-633_Colorize_exception_note","ref":"feture_METH-633_Colorize_exception_note","sha":"b02c7824305c727be586f422c4e29d5465f4883a","user":{"login":"tchevily","id":8125361,"avatar_url":"https://avatars.githubusercontent.com/u/8125361?v=3","gravatar_id":"","url":"https://api.github.com/users/tchevily","html_url":"https://github.com/tchevily","followers_url":"https://api.github.com/users/tchevily/followers","following_url":"https://api.github.com/users/tchevily/following{/other_user}","gists_url":"https://api.github.com/users/tchevily/gists{/gist_id}","starred_url":"https://api.github.com/users/tchevily/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchevily/subscriptions","organizations_url":"https://api.github.com/users/tchevily/orgs","repos_url":"https://api.github.com/users/tchevily/repos","events_url":"https://api.github.com/users/tchevily/events{/privacy}","received_events_url":"https://api.github.com/users/tchevily/received_events","type":"User","site_admin":false},"repo":{"id":55778410,"name":"MttBundle","full_name":"tchevily/MttBundle","owner":{"login":"tchevily","id":8125361,"avatar_url":"https://avatars.githubusercontent.com/u/8125361?v=3","gravatar_id":"","url":"https://api.github.com/users/tchevily","html_url":"https://github.com/tchevily","followers_url":"https://api.github.com/users/tchevily/followers","following_url":"https://api.github.com/users/tchevily/following{/other_user}","gists_url":"https://api.github.com/users/tchevily/gists{/gist_id}","starred_url":"https://api.github.com/users/tchevily/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tchevily/subscriptions","organizations_url":"https://api.github.com/users/tchevily/orgs","repos_url":"https://api.github.com/users/tchevily/repos","events_url":"https://api.github.com/users/tchevily/events{/privacy}","received_events_url":"https://api.github.com/users/tchevily/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tchevily/MttBundle","description":"","fork":true,"url":"https://api.github.com/repos/tchevily/MttBundle","forks_url":"https://api.github.com/repos/tchevily/MttBundle/forks","keys_url":"https://api.github.com/repos/tchevily/MttBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tchevily/MttBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tchevily/MttBundle/teams","hooks_url":"https://api.github.com/repos/tchevily/MttBundle/hooks","issue_events_url":"https://api.github.com/repos/tchevily/MttBundle/issues/events{/number}","events_url":"https://api.github.com/repos/tchevily/MttBundle/events","assignees_url":"https://api.github.com/repos/tchevily/MttBundle/assignees{/user}","branches_url":"https://api.github.com/repos/tchevily/MttBundle/branches{/branch}","tags_url":"https://api.github.com/repos/tchevily/MttBundle/tags","blobs_url":"https://api.github.com/repos/tchevily/MttBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tchevily/MttBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tchevily/MttBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/tchevily/MttBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tchevily/MttBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/tchevily/MttBundle/languages","stargazers_url":"https://api.github.com/repos/tchevily/MttBundle/stargazers","contributors_url":"https://api.github.com/repos/tchevily/MttBundle/contributors","subscribers_url":"https://api.github.com/repos/tchevily/MttBundle/subscribers","subscription_url":"https://api.github.com/repos/tchevily/MttBundle/subscription","commits_url":"https://api.github.com/repos/tchevily/MttBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/tchevily/MttBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/tchevily/MttBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/tchevily/MttBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/tchevily/MttBundle/contents/{+path}","compare_url":"https://api.github.com/repos/tchevily/MttBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tchevily/MttBundle/merges","archive_url":"https://api.github.com/repos/tchevily/MttBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tchevily/MttBundle/downloads","issues_url":"https://api.github.com/repos/tchevily/MttBundle/issues{/number}","pulls_url":"https://api.github.com/repos/tchevily/MttBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/tchevily/MttBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/tchevily/MttBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tchevily/MttBundle/labels{/name}","releases_url":"https://api.github.com/repos/tchevily/MttBundle/releases{/id}","deployments_url":"https://api.github.com/repos/tchevily/MttBundle/deployments","created_at":"2016-04-08T12:46:41Z","updated_at":"2016-04-08T12:46:42Z","pushed_at":"2016-04-12T08:39:44Z","git_url":"git://github.com/tchevily/MttBundle.git","ssh_url":"git@github.com:tchevily/MttBundle.git","clone_url":"https://github.com/tchevily/MttBundle.git","svn_url":"https://github.com/tchevily/MttBundle","homepage":null,"size":3137,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"CanalTP:master","ref":"master","sha":"23e393ad47a0302ed54ca57991fb92dc0e54b55b","user":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?v=3","gravatar_id":"","url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"repo":{"id":26320350,"name":"MttBundle","full_name":"CanalTP/MttBundle","owner":{"login":"CanalTP","id":2743985,"avatar_url":"https://avatars.githubusercontent.com/u/2743985?v=3","gravatar_id":"","url":"https://api.github.com/users/CanalTP","html_url":"https://github.com/CanalTP","followers_url":"https://api.github.com/users/CanalTP/followers","following_url":"https://api.github.com/users/CanalTP/following{/other_user}","gists_url":"https://api.github.com/users/CanalTP/gists{/gist_id}","starred_url":"https://api.github.com/users/CanalTP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CanalTP/subscriptions","organizations_url":"https://api.github.com/users/CanalTP/orgs","repos_url":"https://api.github.com/users/CanalTP/repos","events_url":"https://api.github.com/users/CanalTP/events{/privacy}","received_events_url":"https://api.github.com/users/CanalTP/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/CanalTP/MttBundle","description":"","fork":false,"url":"https://api.github.com/repos/CanalTP/MttBundle","forks_url":"https://api.github.com/repos/CanalTP/MttBundle/forks","keys_url":"https://api.github.com/repos/CanalTP/MttBundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/CanalTP/MttBundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/CanalTP/MttBundle/teams","hooks_url":"https://api.github.com/repos/CanalTP/MttBundle/hooks","issue_events_url":"https://api.github.com/repos/CanalTP/MttBundle/issues/events{/number}","events_url":"https://api.github.com/repos/CanalTP/MttBundle/events","assignees_url":"https://api.github.com/repos/CanalTP/MttBundle/assignees{/user}","branches_url":"https://api.github.com/repos/CanalTP/MttBundle/branches{/branch}","tags_url":"https://api.github.com/repos/CanalTP/MttBundle/tags","blobs_url":"https://api.github.com/repos/CanalTP/MttBundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/CanalTP/MttBundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/CanalTP/MttBundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/CanalTP/MttBundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/CanalTP/MttBundle/statuses/{sha}","languages_url":"https://api.github.com/repos/CanalTP/MttBundle/languages","stargazers_url":"https://api.github.com/repos/CanalTP/MttBundle/stargazers","contributors_url":"https://api.github.com/repos/CanalTP/MttBundle/contributors","subscribers_url":"https://api.github.com/repos/CanalTP/MttBundle/subscribers","subscription_url":"https://api.github.com/repos/CanalTP/MttBundle/subscription","commits_url":"https://api.github.com/repos/CanalTP/MttBundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/CanalTP/MttBundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/CanalTP/MttBundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/CanalTP/MttBundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/CanalTP/MttBundle/contents/{+path}","compare_url":"https://api.github.com/repos/CanalTP/MttBundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/CanalTP/MttBundle/merges","archive_url":"https://api.github.com/repos/CanalTP/MttBundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/CanalTP/MttBundle/downloads","issues_url":"https://api.github.com/repos/CanalTP/MttBundle/issues{/number}","pulls_url":"https://api.github.com/repos/CanalTP/MttBundle/pulls{/number}","milestones_url":"https://api.github.com/repos/CanalTP/MttBundle/milestones{/number}","notifications_url":"https://api.github.com/repos/CanalTP/MttBundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/CanalTP/MttBundle/labels{/name}","releases_url":"https://api.github.com/repos/CanalTP/MttBundle/releases{/id}","deployments_url":"https://api.github.com/repos/CanalTP/MttBundle/deployments","created_at":"2014-11-07T13:16:05Z","updated_at":"2016-01-13T13:47:16Z","pushed_at":"2016-04-12T12:24:55Z","git_url":"git://github.com/CanalTP/MttBundle.git","ssh_url":"git@github.com:CanalTP/MttBundle.git","clone_url":"https://github.com/CanalTP/MttBundle.git","svn_url":"https://github.com/CanalTP/MttBundle","homepage":null,"size":3455,"stargazers_count":4,"watchers_count":4,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":17,"forks":12,"open_issues":17,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102"},"html":{"href":"https://github.com/CanalTP/MttBundle/pull/102"},"issue":{"href":"https://api.github.com/repos/CanalTP/MttBundle/issues/102"},"comments":{"href":"https://api.github.com/repos/CanalTP/MttBundle/issues/102/comments"},"review_comments":{"href":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102/comments"},"review_comment":{"href":"https://api.github.com/repos/CanalTP/MttBundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/CanalTP/MttBundle/pulls/102/commits"},"statuses":{"href":"https://api.github.com/repos/CanalTP/MttBundle/statuses/b02c7824305c727be586f422c4e29d5465f4883a"}}}}