{"action":"created","comment":{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/comments/25761275","id":25761275,"diff_hunk":"@@ -0,0 +1,218 @@\n+<?php\n+\n+/**\n+ * Contains the description of a user query\n+ * \n+ * It allows to extract the meaningful bits of the query to be manipulated in an\n+ * easy way.\n+ */\n+class FreshRSS_UserQuery {\n+\n+\tprivate $deprecated = false;\n+\tprivate $get;\n+\tprivate $get_name;\n+\tprivate $get_type;\n+\tprivate $name;\n+\tprivate $order;\n+\tprivate $search;\n+\tprivate $state;\n+\tprivate $url;\n+\tprivate $feed_dao;\n+\tprivate $category_dao;\n+\n+\t/**\n+\t * @param array $query\n+\t * @param FreshRSS_Searchable $feed_dao\n+\t * @param FreshRSS_Searchable $category_dao\n+\t */\n+\tpublic function __construct($query, FreshRSS_Searchable $feed_dao = null, FreshRSS_Searchable $category_dao = null) {\n+\t\t$this->category_dao = $category_dao;\n+\t\t$this->feed_dao = $feed_dao;\n+\t\tif (isset($query['get'])) {\n+\t\t\t$this->parseGet($query['get']);\n+\t\t}\n+\t\tif (isset($query['name'])) {\n+\t\t\t$this->name = $query['name'];\n+\t\t}\n+\t\tif (isset($query['order'])) {\n+\t\t\t$this->order = $query['order'];\n+\t\t}\n+\t\tif (!isset($query['search'])) {\n+\t\t\t$query['search'] = '';\n+\t\t}\n+\t\t// linked to deeply with the search object, need to use dependency injection\n+\t\t$this->search = new FreshRSS_Search($query['search']);\n+\t\tif (isset($query['state'])) {\n+\t\t\t$this->state = $query['state'];\n+\t\t}\n+\t\tif (isset($query['url'])) {\n+\t\t\t$this->url = $query['url'];\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * Convert the current object to an array.\n+\t * \n+\t * @return array\n+\t */\n+\tpublic function toArray() {\n+\t\treturn array_filter(array(\n+\t\t    'get' => $this->get,\n+\t\t    'name' => $this->name,\n+\t\t    'order' => $this->order,\n+\t\t    'search' => $this->search->__toString(),\n+\t\t    'state' => $this->state,\n+\t\t    'url' => $this->url,\n+\t\t));\n+\t}\n+\n+\t/**\n+\t * Parse the get parameter in the query string to extract its name and\n+\t * type\n+\t * \n+\t * @param string $get\n+\t */\n+\tprivate function parseGet($get) {\n+\t\t$this->get = $get;\n+\t\tif (preg_match('/(?P<type>[acfs])(_(?P<id>\\d+))?/', $get, $matches)) {\n+\t\t\tswitch ($matches['type']) {\n+\t\t\t\tcase 'a':\n+\t\t\t\t\t$this->parseAll();\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase 'c':\n+\t\t\t\t\t$this->parseCategory($matches['id']);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase 'f':\n+\t\t\t\t\t$this->parseFeed($matches['id']);\n+\t\t\t\t\tbreak;\n+\t\t\t\tcase 's':\n+\t\t\t\t\t$this->parseFavorite();\n+\t\t\t\t\tbreak;\n+\t\t\t}\n+\t\t}\n+\t}\n+\n+\t/**\n+\t * Parse the query string when it is an \"all\" query\n+\t */\n+\tprivate function parseAll() {\n+\t\t$this->get_name = 'all';\n+\t\t$this->get_type = 'all';\n+\t}\n+\n+\t/**\n+\t * Parse the query string when it is a \"category\" query\n+\t * \n+\t * @param integer $id\n+\t */\n+\tprivate function parseCategory($id) {\n+\t\t$category = $this->category_dao->searchById($id);","path":"app/Models/UserQuery.php","position":109,"original_position":109,"commit_id":"a573954087bc719341fe35f282aead534eabbaf7","original_commit_id":"a573954087bc719341fe35f282aead534eabbaf7","user":{"login":"marienfressinaud","id":1436309,"avatar_url":"https://avatars.githubusercontent.com/u/1436309?v=3","gravatar_id":"","url":"https://api.github.com/users/marienfressinaud","html_url":"https://github.com/marienfressinaud","followers_url":"https://api.github.com/users/marienfressinaud/followers","following_url":"https://api.github.com/users/marienfressinaud/following{/other_user}","gists_url":"https://api.github.com/users/marienfressinaud/gists{/gist_id}","starred_url":"https://api.github.com/users/marienfressinaud/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/marienfressinaud/subscriptions","organizations_url":"https://api.github.com/users/marienfressinaud/orgs","repos_url":"https://api.github.com/users/marienfressinaud/repos","events_url":"https://api.github.com/users/marienfressinaud/events{/privacy}","received_events_url":"https://api.github.com/users/marienfressinaud/received_events","type":"User","site_admin":false},"body":"You should test `category_dao` is not null since it is optional in the constructor (i.e. default value at null)","created_at":"2015-03-04T09:25:16Z","updated_at":"2015-03-04T09:25:16Z","html_url":"https://github.com/FreshRSS/FreshRSS/pull/799#discussion_r25761275","pull_request_url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799","_links":{"self":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/comments/25761275"},"html":{"href":"https://github.com/FreshRSS/FreshRSS/pull/799#discussion_r25761275"},"pull_request":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799"}}},"pull_request":{"url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799","id":30242629,"html_url":"https://github.com/FreshRSS/FreshRSS/pull/799","diff_url":"https://github.com/FreshRSS/FreshRSS/pull/799.diff","patch_url":"https://github.com/FreshRSS/FreshRSS/pull/799.patch","issue_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/799","number":799,"state":"open","locked":false,"title":"Introduce user queries objects","user":{"login":"aledeg","id":3056148,"avatar_url":"https://avatars.githubusercontent.com/u/3056148?v=3","gravatar_id":"","url":"https://api.github.com/users/aledeg","html_url":"https://github.com/aledeg","followers_url":"https://api.github.com/users/aledeg/followers","following_url":"https://api.github.com/users/aledeg/following{/other_user}","gists_url":"https://api.github.com/users/aledeg/gists{/gist_id}","starred_url":"https://api.github.com/users/aledeg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aledeg/subscriptions","organizations_url":"https://api.github.com/users/aledeg/orgs","repos_url":"https://api.github.com/users/aledeg/repos","events_url":"https://api.github.com/users/aledeg/events{/privacy}","received_events_url":"https://api.github.com/users/aledeg/received_events","type":"User","site_admin":false},"body":"There is now an object to manipulate user queries. It allows to move logic to handle those from the view and the controller in the model.\r\nThus making the view and the controller easier to read.\r\nI introduced a new interface to start using dependency injection. There is still some rough edges but we are moving in the right direction.\r\nThe new object is fully tested but it still need some improvements, for instance, it is still tied to the search object.\r\nThere might be a better way to do that.","created_at":"2015-03-01T14:24:36Z","updated_at":"2015-03-04T09:25:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1bb1e2f746ea734f3cc2cda19ba18d40c913f22f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799/commits","review_comments_url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799/comments","review_comment_url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/799/comments","statuses_url":"https://api.github.com/repos/FreshRSS/FreshRSS/statuses/a573954087bc719341fe35f282aead534eabbaf7","head":{"label":"aledeg:user-queries","ref":"user-queries","sha":"a573954087bc719341fe35f282aead534eabbaf7","user":{"login":"aledeg","id":3056148,"avatar_url":"https://avatars.githubusercontent.com/u/3056148?v=3","gravatar_id":"","url":"https://api.github.com/users/aledeg","html_url":"https://github.com/aledeg","followers_url":"https://api.github.com/users/aledeg/followers","following_url":"https://api.github.com/users/aledeg/following{/other_user}","gists_url":"https://api.github.com/users/aledeg/gists{/gist_id}","starred_url":"https://api.github.com/users/aledeg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aledeg/subscriptions","organizations_url":"https://api.github.com/users/aledeg/orgs","repos_url":"https://api.github.com/users/aledeg/repos","events_url":"https://api.github.com/users/aledeg/events{/privacy}","received_events_url":"https://api.github.com/users/aledeg/received_events","type":"User","site_admin":false},"repo":{"id":14469014,"name":"FreshRSS","full_name":"aledeg/FreshRSS","owner":{"login":"aledeg","id":3056148,"avatar_url":"https://avatars.githubusercontent.com/u/3056148?v=3","gravatar_id":"","url":"https://api.github.com/users/aledeg","html_url":"https://github.com/aledeg","followers_url":"https://api.github.com/users/aledeg/followers","following_url":"https://api.github.com/users/aledeg/following{/other_user}","gists_url":"https://api.github.com/users/aledeg/gists{/gist_id}","starred_url":"https://api.github.com/users/aledeg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aledeg/subscriptions","organizations_url":"https://api.github.com/users/aledeg/orgs","repos_url":"https://api.github.com/users/aledeg/repos","events_url":"https://api.github.com/users/aledeg/events{/privacy}","received_events_url":"https://api.github.com/users/aledeg/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/aledeg/FreshRSS","description":"Un agrégateur de flux RSS à auto-héberger","fork":true,"url":"https://api.github.com/repos/aledeg/FreshRSS","forks_url":"https://api.github.com/repos/aledeg/FreshRSS/forks","keys_url":"https://api.github.com/repos/aledeg/FreshRSS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aledeg/FreshRSS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aledeg/FreshRSS/teams","hooks_url":"https://api.github.com/repos/aledeg/FreshRSS/hooks","issue_events_url":"https://api.github.com/repos/aledeg/FreshRSS/issues/events{/number}","events_url":"https://api.github.com/repos/aledeg/FreshRSS/events","assignees_url":"https://api.github.com/repos/aledeg/FreshRSS/assignees{/user}","branches_url":"https://api.github.com/repos/aledeg/FreshRSS/branches{/branch}","tags_url":"https://api.github.com/repos/aledeg/FreshRSS/tags","blobs_url":"https://api.github.com/repos/aledeg/FreshRSS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aledeg/FreshRSS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aledeg/FreshRSS/git/refs{/sha}","trees_url":"https://api.github.com/repos/aledeg/FreshRSS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aledeg/FreshRSS/statuses/{sha}","languages_url":"https://api.github.com/repos/aledeg/FreshRSS/languages","stargazers_url":"https://api.github.com/repos/aledeg/FreshRSS/stargazers","contributors_url":"https://api.github.com/repos/aledeg/FreshRSS/contributors","subscribers_url":"https://api.github.com/repos/aledeg/FreshRSS/subscribers","subscription_url":"https://api.github.com/repos/aledeg/FreshRSS/subscription","commits_url":"https://api.github.com/repos/aledeg/FreshRSS/commits{/sha}","git_commits_url":"https://api.github.com/repos/aledeg/FreshRSS/git/commits{/sha}","comments_url":"https://api.github.com/repos/aledeg/FreshRSS/comments{/number}","issue_comment_url":"https://api.github.com/repos/aledeg/FreshRSS/issues/comments{/number}","contents_url":"https://api.github.com/repos/aledeg/FreshRSS/contents/{+path}","compare_url":"https://api.github.com/repos/aledeg/FreshRSS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aledeg/FreshRSS/merges","archive_url":"https://api.github.com/repos/aledeg/FreshRSS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aledeg/FreshRSS/downloads","issues_url":"https://api.github.com/repos/aledeg/FreshRSS/issues{/number}","pulls_url":"https://api.github.com/repos/aledeg/FreshRSS/pulls{/number}","milestones_url":"https://api.github.com/repos/aledeg/FreshRSS/milestones{/number}","notifications_url":"https://api.github.com/repos/aledeg/FreshRSS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aledeg/FreshRSS/labels{/name}","releases_url":"https://api.github.com/repos/aledeg/FreshRSS/releases{/id}","created_at":"2013-11-17T15:20:47Z","updated_at":"2014-08-28T15:12:29Z","pushed_at":"2015-03-04T03:37:32Z","git_url":"git://github.com/aledeg/FreshRSS.git","ssh_url":"git@github.com:aledeg/FreshRSS.git","clone_url":"https://github.com/aledeg/FreshRSS.git","svn_url":"https://github.com/aledeg/FreshRSS","homepage":"http://marienfressinaud.github.io/FreshRSS/","size":6386,"stargazers_count":0,"watchers_count":0,"language":"PHP","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"beta"}},"base":{"label":"FreshRSS:dev","ref":"dev","sha":"cdd653ce5305f043ee1db970c25303676c9f35c0","user":{"login":"FreshRSS","id":9414285,"avatar_url":"https://avatars.githubusercontent.com/u/9414285?v=3","gravatar_id":"","url":"https://api.github.com/users/FreshRSS","html_url":"https://github.com/FreshRSS","followers_url":"https://api.github.com/users/FreshRSS/followers","following_url":"https://api.github.com/users/FreshRSS/following{/other_user}","gists_url":"https://api.github.com/users/FreshRSS/gists{/gist_id}","starred_url":"https://api.github.com/users/FreshRSS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreshRSS/subscriptions","organizations_url":"https://api.github.com/users/FreshRSS/orgs","repos_url":"https://api.github.com/users/FreshRSS/repos","events_url":"https://api.github.com/users/FreshRSS/events{/privacy}","received_events_url":"https://api.github.com/users/FreshRSS/received_events","type":"Organization","site_admin":false},"repo":{"id":6322699,"name":"FreshRSS","full_name":"FreshRSS/FreshRSS","owner":{"login":"FreshRSS","id":9414285,"avatar_url":"https://avatars.githubusercontent.com/u/9414285?v=3","gravatar_id":"","url":"https://api.github.com/users/FreshRSS","html_url":"https://github.com/FreshRSS","followers_url":"https://api.github.com/users/FreshRSS/followers","following_url":"https://api.github.com/users/FreshRSS/following{/other_user}","gists_url":"https://api.github.com/users/FreshRSS/gists{/gist_id}","starred_url":"https://api.github.com/users/FreshRSS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FreshRSS/subscriptions","organizations_url":"https://api.github.com/users/FreshRSS/orgs","repos_url":"https://api.github.com/users/FreshRSS/repos","events_url":"https://api.github.com/users/FreshRSS/events{/privacy}","received_events_url":"https://api.github.com/users/FreshRSS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/FreshRSS/FreshRSS","description":"A free, self-hostable aggregator…","fork":false,"url":"https://api.github.com/repos/FreshRSS/FreshRSS","forks_url":"https://api.github.com/repos/FreshRSS/FreshRSS/forks","keys_url":"https://api.github.com/repos/FreshRSS/FreshRSS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/FreshRSS/FreshRSS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/FreshRSS/FreshRSS/teams","hooks_url":"https://api.github.com/repos/FreshRSS/FreshRSS/hooks","issue_events_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/events{/number}","events_url":"https://api.github.com/repos/FreshRSS/FreshRSS/events","assignees_url":"https://api.github.com/repos/FreshRSS/FreshRSS/assignees{/user}","branches_url":"https://api.github.com/repos/FreshRSS/FreshRSS/branches{/branch}","tags_url":"https://api.github.com/repos/FreshRSS/FreshRSS/tags","blobs_url":"https://api.github.com/repos/FreshRSS/FreshRSS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/FreshRSS/FreshRSS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/FreshRSS/FreshRSS/git/refs{/sha}","trees_url":"https://api.github.com/repos/FreshRSS/FreshRSS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/FreshRSS/FreshRSS/statuses/{sha}","languages_url":"https://api.github.com/repos/FreshRSS/FreshRSS/languages","stargazers_url":"https://api.github.com/repos/FreshRSS/FreshRSS/stargazers","contributors_url":"https://api.github.com/repos/FreshRSS/FreshRSS/contributors","subscribers_url":"https://api.github.com/repos/FreshRSS/FreshRSS/subscribers","subscription_url":"https://api.github.com/repos/FreshRSS/FreshRSS/subscription","commits_url":"https://api.github.com/repos/FreshRSS/FreshRSS/commits{/sha}","git_commits_url":"https://api.github.com/repos/FreshRSS/FreshRSS/git/commits{/sha}","comments_url":"https://api.github.com/repos/FreshRSS/FreshRSS/comments{/number}","issue_comment_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/comments{/number}","contents_url":"https://api.github.com/repos/FreshRSS/FreshRSS/contents/{+path}","compare_url":"https://api.github.com/repos/FreshRSS/FreshRSS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/FreshRSS/FreshRSS/merges","archive_url":"https://api.github.com/repos/FreshRSS/FreshRSS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/FreshRSS/FreshRSS/downloads","issues_url":"https://api.github.com/repos/FreshRSS/FreshRSS/issues{/number}","pulls_url":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls{/number}","milestones_url":"https://api.github.com/repos/FreshRSS/FreshRSS/milestones{/number}","notifications_url":"https://api.github.com/repos/FreshRSS/FreshRSS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/FreshRSS/FreshRSS/labels{/name}","releases_url":"https://api.github.com/repos/FreshRSS/FreshRSS/releases{/id}","created_at":"2012-10-21T16:48:50Z","updated_at":"2015-03-03T12:01:29Z","pushed_at":"2015-03-04T07:40:40Z","git_url":"git://github.com/FreshRSS/FreshRSS.git","ssh_url":"git@github.com:FreshRSS/FreshRSS.git","clone_url":"https://github.com/FreshRSS/FreshRSS.git","svn_url":"https://github.com/FreshRSS/FreshRSS","homepage":"http://freshrss.org","size":9269,"stargazers_count":213,"watchers_count":213,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":35,"mirror_url":null,"open_issues_count":99,"forks":35,"open_issues":99,"watchers":213,"default_branch":"beta"}},"_links":{"self":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799"},"html":{"href":"https://github.com/FreshRSS/FreshRSS/pull/799"},"issue":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/799"},"comments":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/issues/799/comments"},"review_comments":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799/comments"},"review_comment":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/pulls/799/commits"},"statuses":{"href":"https://api.github.com/repos/FreshRSS/FreshRSS/statuses/a573954087bc719341fe35f282aead534eabbaf7"}}}}