{"action":"created","comment":{"url":"https://api.github.com/repos/unikent/lib-php-kar/pulls/comments/24093085","id":24093085,"diff_hunk":"@@ -0,0 +1,223 @@\n+<?php\n+/**\n+ * KAR API for is-dev applications.\n+ *\n+ * @copyright  2014 Skylar Kelty <S.Kelty@kent.ac.uk>\n+ * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later\n+ */\n+\n+namespace unikent\\KAR;\n+\n+/**\n+ * A division, as KAR sees them.\n+ * This is also a doubly linked list.\n+ */\n+class Division\n+{\n+    /**\n+     * API.\n+     * \n+     * @internal\n+     * @param object\n+     */\n+    private $_api;\n+\n+    /**\n+     * Parent.\n+     * \n+     * @internal\n+     * @param object\n+     */\n+    private $_parent;\n+\n+    /**\n+     * Children.\n+     * \n+     * @internal\n+     * @param object\n+     */\n+    private $_child;\n+\n+    /**\n+     * ID.\n+     * \n+     * @internal\n+     * @param string\n+     */\n+    private $_id;\n+\n+    /**\n+     * Name.\n+     * \n+     * @internal\n+     * @param string\n+     */\n+    private $_name;\n+\n+    /**\n+     * Constructor.\n+     *\n+     * @internal\n+     * @param object $api The API we are related to.\n+     */\n+    private function __construct($api) {\n+        $this->_api = $api;\n+    }\n+\n+    /**\n+     * Create a division from a JSON object.\n+     *\n+     * @internal\n+     * @param object $api The API we are related to.\n+     * @param object $data The data.\n+     */\n+    public static function create_from_api($api, $data) {\n+        $obj = new static($api);\n+        $obj->_id = $data->id;\n+        $obj->_name = $data->name;\n+        $obj->_parent = null;\n+        $obj->_child = null;\n+\n+        return $obj;\n+    }\n+\n+    /**\n+     * Create a divisions path from a JSON object.\n+     *\n+     * @internal\n+     * @param object $api The API we are related to.\n+     * @param object $path The path.\n+     */\n+    private static function create_path($api, $path) {\n+        krsort($path);\n+\n+        $curr = null;\n+        foreach ($path as $child) {\n+            $division = static::create_from_api($api, $child);\n+            if ($curr) {\n+                $curr->set_child($division);\n+            }\n+            $curr = $division;\n+        }\n+\n+        return $curr;\n+    }\n+\n+    /**\n+     * Create a divisions path from a JSON object.\n+     *\n+     * @internal\n+     * @param object $api The API we are related to.\n+     * @param object $divisions The data.\n+     */\n+    public static function create_paths_from_api($api, $divisions) {\n+        // Split it up into bits.\n+        $paths = array();\n+        foreach ($divisions as $division) {\n+            $id = $division->division;\n+            $pos = $division->subject;\n+\n+            if (!isset($id)) {\n+                $paths[$id] = array();\n+            }\n+\n+            $paths[$id][$pos] = $division;\n+        }\n+\n+        $ret = array();\n+        foreach ($paths as $id => $path) {\n+            $path = static::create_path($api, $path);\n+            $ret[] = $path->get_last();\n+        }\n+\n+        return $ret;\n+    }\n+\n+    /**\n+     * Set my child.\n+     *\n+     * @internal\n+     */\n+    private function set_child($child) {","path":"src/Division.php","position":141,"original_position":141,"commit_id":"c9c4f72b3900d81033537cf942dfaf7ad60ed093","original_commit_id":"c9c4f72b3900d81033537cf942dfaf7ad60ed093","user":{"login":"linthubot","id":10566297,"avatar_url":"https://avatars.githubusercontent.com/u/10566297?v=3","gravatar_id":"","url":"https://api.github.com/users/linthubot","html_url":"https://github.com/linthubot","followers_url":"https://api.github.com/users/linthubot/followers","following_url":"https://api.github.com/users/linthubot/following{/other_user}","gists_url":"https://api.github.com/users/linthubot/gists{/gist_id}","starred_url":"https://api.github.com/users/linthubot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/linthubot/subscriptions","organizations_url":"https://api.github.com/users/linthubot/orgs","repos_url":"https://api.github.com/users/linthubot/repos","events_url":"https://api.github.com/users/linthubot/events{/privacy}","received_events_url":"https://api.github.com/users/linthubot/received_events","type":"User","site_admin":false},"body":"**PSR1.Methods.CamelCapsMethodName.NotCamelCaps**: Method name &#34;Division::set_child&#34; is not in camel caps format\n**Squiz.Functions.MultiLineFunctionDeclaration.BraceOnSameLine**: Opening brace should be on a new line","created_at":"2015-02-04T15:56:57Z","updated_at":"2015-02-04T15:56:57Z","html_url":"https://github.com/unikent/lib-php-kar/pull/4#discussion_r24093085","pull_request_url":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/unikent/lib-php-kar/pulls/comments/24093085"},"html":{"href":"https://github.com/unikent/lib-php-kar/pull/4#discussion_r24093085"},"pull_request":{"href":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4","id":28649298,"html_url":"https://github.com/unikent/lib-php-kar/pull/4","diff_url":"https://github.com/unikent/lib-php-kar/pull/4.diff","patch_url":"https://github.com/unikent/lib-php-kar/pull/4.patch","issue_url":"https://api.github.com/repos/unikent/lib-php-kar/issues/4","number":4,"state":"open","locked":false,"title":"Feature/new api","user":{"login":"sk-unikent","id":4242976,"avatar_url":"https://avatars.githubusercontent.com/u/4242976?v=3","gravatar_id":"","url":"https://api.github.com/users/sk-unikent","html_url":"https://github.com/sk-unikent","followers_url":"https://api.github.com/users/sk-unikent/followers","following_url":"https://api.github.com/users/sk-unikent/following{/other_user}","gists_url":"https://api.github.com/users/sk-unikent/gists{/gist_id}","starred_url":"https://api.github.com/users/sk-unikent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sk-unikent/subscriptions","organizations_url":"https://api.github.com/users/sk-unikent/orgs","repos_url":"https://api.github.com/users/sk-unikent/repos","events_url":"https://api.github.com/users/sk-unikent/events{/privacy}","received_events_url":"https://api.github.com/users/sk-unikent/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-04T15:56:23Z","updated_at":"2015-02-04T15:56:57Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e1cbfc10edd428a80fcab82676eb32fb9f618202","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4/commits","review_comments_url":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4/comments","review_comment_url":"https://api.github.com/repos/unikent/lib-php-kar/pulls/comments/{number}","comments_url":"https://api.github.com/repos/unikent/lib-php-kar/issues/4/comments","statuses_url":"https://api.github.com/repos/unikent/lib-php-kar/statuses/c9c4f72b3900d81033537cf942dfaf7ad60ed093","head":{"label":"unikent:feature/new-api","ref":"feature/new-api","sha":"c9c4f72b3900d81033537cf942dfaf7ad60ed093","user":{"login":"unikent","id":948236,"avatar_url":"https://avatars.githubusercontent.com/u/948236?v=3","gravatar_id":"","url":"https://api.github.com/users/unikent","html_url":"https://github.com/unikent","followers_url":"https://api.github.com/users/unikent/followers","following_url":"https://api.github.com/users/unikent/following{/other_user}","gists_url":"https://api.github.com/users/unikent/gists{/gist_id}","starred_url":"https://api.github.com/users/unikent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unikent/subscriptions","organizations_url":"https://api.github.com/users/unikent/orgs","repos_url":"https://api.github.com/users/unikent/repos","events_url":"https://api.github.com/users/unikent/events{/privacy}","received_events_url":"https://api.github.com/users/unikent/received_events","type":"Organization","site_admin":false},"repo":{"id":27422110,"name":"lib-php-kar","full_name":"unikent/lib-php-kar","owner":{"login":"unikent","id":948236,"avatar_url":"https://avatars.githubusercontent.com/u/948236?v=3","gravatar_id":"","url":"https://api.github.com/users/unikent","html_url":"https://github.com/unikent","followers_url":"https://api.github.com/users/unikent/followers","following_url":"https://api.github.com/users/unikent/following{/other_user}","gists_url":"https://api.github.com/users/unikent/gists{/gist_id}","starred_url":"https://api.github.com/users/unikent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unikent/subscriptions","organizations_url":"https://api.github.com/users/unikent/orgs","repos_url":"https://api.github.com/users/unikent/repos","events_url":"https://api.github.com/users/unikent/events{/privacy}","received_events_url":"https://api.github.com/users/unikent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/unikent/lib-php-kar","description":"KAR API in PHP","fork":false,"url":"https://api.github.com/repos/unikent/lib-php-kar","forks_url":"https://api.github.com/repos/unikent/lib-php-kar/forks","keys_url":"https://api.github.com/repos/unikent/lib-php-kar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/unikent/lib-php-kar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/unikent/lib-php-kar/teams","hooks_url":"https://api.github.com/repos/unikent/lib-php-kar/hooks","issue_events_url":"https://api.github.com/repos/unikent/lib-php-kar/issues/events{/number}","events_url":"https://api.github.com/repos/unikent/lib-php-kar/events","assignees_url":"https://api.github.com/repos/unikent/lib-php-kar/assignees{/user}","branches_url":"https://api.github.com/repos/unikent/lib-php-kar/branches{/branch}","tags_url":"https://api.github.com/repos/unikent/lib-php-kar/tags","blobs_url":"https://api.github.com/repos/unikent/lib-php-kar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/unikent/lib-php-kar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/unikent/lib-php-kar/git/refs{/sha}","trees_url":"https://api.github.com/repos/unikent/lib-php-kar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/unikent/lib-php-kar/statuses/{sha}","languages_url":"https://api.github.com/repos/unikent/lib-php-kar/languages","stargazers_url":"https://api.github.com/repos/unikent/lib-php-kar/stargazers","contributors_url":"https://api.github.com/repos/unikent/lib-php-kar/contributors","subscribers_url":"https://api.github.com/repos/unikent/lib-php-kar/subscribers","subscription_url":"https://api.github.com/repos/unikent/lib-php-kar/subscription","commits_url":"https://api.github.com/repos/unikent/lib-php-kar/commits{/sha}","git_commits_url":"https://api.github.com/repos/unikent/lib-php-kar/git/commits{/sha}","comments_url":"https://api.github.com/repos/unikent/lib-php-kar/comments{/number}","issue_comment_url":"https://api.github.com/repos/unikent/lib-php-kar/issues/comments/{number}","contents_url":"https://api.github.com/repos/unikent/lib-php-kar/contents/{+path}","compare_url":"https://api.github.com/repos/unikent/lib-php-kar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/unikent/lib-php-kar/merges","archive_url":"https://api.github.com/repos/unikent/lib-php-kar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/unikent/lib-php-kar/downloads","issues_url":"https://api.github.com/repos/unikent/lib-php-kar/issues{/number}","pulls_url":"https://api.github.com/repos/unikent/lib-php-kar/pulls{/number}","milestones_url":"https://api.github.com/repos/unikent/lib-php-kar/milestones{/number}","notifications_url":"https://api.github.com/repos/unikent/lib-php-kar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/unikent/lib-php-kar/labels{/name}","releases_url":"https://api.github.com/repos/unikent/lib-php-kar/releases{/id}","created_at":"2014-12-02T08:12:22Z","updated_at":"2015-02-04T10:58:52Z","pushed_at":"2015-02-04T15:54:32Z","git_url":"git://github.com/unikent/lib-php-kar.git","ssh_url":"git@github.com:unikent/lib-php-kar.git","clone_url":"https://github.com/unikent/lib-php-kar.git","svn_url":"https://github.com/unikent/lib-php-kar","homepage":null,"size":924,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"unikent:master","ref":"master","sha":"163de06e96c02ea3119d9ed63700538daf412466","user":{"login":"unikent","id":948236,"avatar_url":"https://avatars.githubusercontent.com/u/948236?v=3","gravatar_id":"","url":"https://api.github.com/users/unikent","html_url":"https://github.com/unikent","followers_url":"https://api.github.com/users/unikent/followers","following_url":"https://api.github.com/users/unikent/following{/other_user}","gists_url":"https://api.github.com/users/unikent/gists{/gist_id}","starred_url":"https://api.github.com/users/unikent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unikent/subscriptions","organizations_url":"https://api.github.com/users/unikent/orgs","repos_url":"https://api.github.com/users/unikent/repos","events_url":"https://api.github.com/users/unikent/events{/privacy}","received_events_url":"https://api.github.com/users/unikent/received_events","type":"Organization","site_admin":false},"repo":{"id":27422110,"name":"lib-php-kar","full_name":"unikent/lib-php-kar","owner":{"login":"unikent","id":948236,"avatar_url":"https://avatars.githubusercontent.com/u/948236?v=3","gravatar_id":"","url":"https://api.github.com/users/unikent","html_url":"https://github.com/unikent","followers_url":"https://api.github.com/users/unikent/followers","following_url":"https://api.github.com/users/unikent/following{/other_user}","gists_url":"https://api.github.com/users/unikent/gists{/gist_id}","starred_url":"https://api.github.com/users/unikent/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/unikent/subscriptions","organizations_url":"https://api.github.com/users/unikent/orgs","repos_url":"https://api.github.com/users/unikent/repos","events_url":"https://api.github.com/users/unikent/events{/privacy}","received_events_url":"https://api.github.com/users/unikent/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/unikent/lib-php-kar","description":"KAR API in PHP","fork":false,"url":"https://api.github.com/repos/unikent/lib-php-kar","forks_url":"https://api.github.com/repos/unikent/lib-php-kar/forks","keys_url":"https://api.github.com/repos/unikent/lib-php-kar/keys{/key_id}","collaborators_url":"https://api.github.com/repos/unikent/lib-php-kar/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/unikent/lib-php-kar/teams","hooks_url":"https://api.github.com/repos/unikent/lib-php-kar/hooks","issue_events_url":"https://api.github.com/repos/unikent/lib-php-kar/issues/events{/number}","events_url":"https://api.github.com/repos/unikent/lib-php-kar/events","assignees_url":"https://api.github.com/repos/unikent/lib-php-kar/assignees{/user}","branches_url":"https://api.github.com/repos/unikent/lib-php-kar/branches{/branch}","tags_url":"https://api.github.com/repos/unikent/lib-php-kar/tags","blobs_url":"https://api.github.com/repos/unikent/lib-php-kar/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/unikent/lib-php-kar/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/unikent/lib-php-kar/git/refs{/sha}","trees_url":"https://api.github.com/repos/unikent/lib-php-kar/git/trees{/sha}","statuses_url":"https://api.github.com/repos/unikent/lib-php-kar/statuses/{sha}","languages_url":"https://api.github.com/repos/unikent/lib-php-kar/languages","stargazers_url":"https://api.github.com/repos/unikent/lib-php-kar/stargazers","contributors_url":"https://api.github.com/repos/unikent/lib-php-kar/contributors","subscribers_url":"https://api.github.com/repos/unikent/lib-php-kar/subscribers","subscription_url":"https://api.github.com/repos/unikent/lib-php-kar/subscription","commits_url":"https://api.github.com/repos/unikent/lib-php-kar/commits{/sha}","git_commits_url":"https://api.github.com/repos/unikent/lib-php-kar/git/commits{/sha}","comments_url":"https://api.github.com/repos/unikent/lib-php-kar/comments{/number}","issue_comment_url":"https://api.github.com/repos/unikent/lib-php-kar/issues/comments/{number}","contents_url":"https://api.github.com/repos/unikent/lib-php-kar/contents/{+path}","compare_url":"https://api.github.com/repos/unikent/lib-php-kar/compare/{base}...{head}","merges_url":"https://api.github.com/repos/unikent/lib-php-kar/merges","archive_url":"https://api.github.com/repos/unikent/lib-php-kar/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/unikent/lib-php-kar/downloads","issues_url":"https://api.github.com/repos/unikent/lib-php-kar/issues{/number}","pulls_url":"https://api.github.com/repos/unikent/lib-php-kar/pulls{/number}","milestones_url":"https://api.github.com/repos/unikent/lib-php-kar/milestones{/number}","notifications_url":"https://api.github.com/repos/unikent/lib-php-kar/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/unikent/lib-php-kar/labels{/name}","releases_url":"https://api.github.com/repos/unikent/lib-php-kar/releases{/id}","created_at":"2014-12-02T08:12:22Z","updated_at":"2015-02-04T10:58:52Z","pushed_at":"2015-02-04T15:54:32Z","git_url":"git://github.com/unikent/lib-php-kar.git","ssh_url":"git@github.com:unikent/lib-php-kar.git","clone_url":"https://github.com/unikent/lib-php-kar.git","svn_url":"https://github.com/unikent/lib-php-kar","homepage":null,"size":924,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4"},"html":{"href":"https://github.com/unikent/lib-php-kar/pull/4"},"issue":{"href":"https://api.github.com/repos/unikent/lib-php-kar/issues/4"},"comments":{"href":"https://api.github.com/repos/unikent/lib-php-kar/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/unikent/lib-php-kar/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/unikent/lib-php-kar/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/unikent/lib-php-kar/statuses/c9c4f72b3900d81033537cf942dfaf7ad60ed093"}}}}