{"action":"created","issue":{"url":"https://api.github.com/repos/FlameCore/UserAgent/issues/1","labels_url":"https://api.github.com/repos/FlameCore/UserAgent/issues/1/labels{/name}","comments_url":"https://api.github.com/repos/FlameCore/UserAgent/issues/1/comments","events_url":"https://api.github.com/repos/FlameCore/UserAgent/issues/1/events","html_url":"https://github.com/FlameCore/UserAgent/pull/1","id":106616403,"number":1,"title":"Implements the proposed modifications from /u/akeniscool, with static methods to create immutable objects.","user":{"login":"naroga","id":3511149,"avatar_url":"https://avatars.githubusercontent.com/u/3511149?v=3","gravatar_id":"","url":"https://api.github.com/users/naroga","html_url":"https://github.com/naroga","followers_url":"https://api.github.com/users/naroga/followers","following_url":"https://api.github.com/users/naroga/following{/other_user}","gists_url":"https://api.github.com/users/naroga/gists{/gist_id}","starred_url":"https://api.github.com/users/naroga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/naroga/subscriptions","organizations_url":"https://api.github.com/users/naroga/orgs","repos_url":"https://api.github.com/users/naroga/repos","events_url":"https://api.github.com/users/naroga/events{/privacy}","received_events_url":"https://api.github.com/users/naroga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":8,"created_at":"2015-09-15T18:28:48Z","updated_at":"2015-09-17T17:50:58Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/FlameCore/UserAgent/pulls/1","html_url":"https://github.com/FlameCore/UserAgent/pull/1","diff_url":"https://github.com/FlameCore/UserAgent/pull/1.diff","patch_url":"https://github.com/FlameCore/UserAgent/pull/1.patch"},"body":"As proposed by /u/akeniscool:\r\n\r\n    I think the flow and the resulting API is more complicated than it needs to be, blending together the parsing/factory portion of the library with the resulting UserAgent entity. I would rather see something like a static factory that is explicit about what data is being parsed:\r\n    $userAgent = UserAgentParser::parse($_SERVER['HTTP_USER_AGENT']);\r\n\r\n    // Equivalent default, yet still explicit.\r\n    $userAgent = UserAgentParser::parseFromGlobal();\r\n    These methods would parse the information specified, and return an immutable UserAgent entity (no setters!).\r\n\r\nThis PR removes all public setters from the UserAgent, makes the default constructor private and adds two methods to create immutable objects: `::create($string, $parser)` and `::createFromGlobal()`."},"comment":{"url":"https://api.github.com/repos/FlameCore/UserAgent/issues/comments/141165045","html_url":"https://github.com/FlameCore/UserAgent/pull/1#issuecomment-141165045","issue_url":"https://api.github.com/repos/FlameCore/UserAgent/issues/1","id":141165045,"user":{"login":"cryode","id":563886,"avatar_url":"https://avatars.githubusercontent.com/u/563886?v=3","gravatar_id":"","url":"https://api.github.com/users/cryode","html_url":"https://github.com/cryode","followers_url":"https://api.github.com/users/cryode/followers","following_url":"https://api.github.com/users/cryode/following{/other_user}","gists_url":"https://api.github.com/users/cryode/gists{/gist_id}","starred_url":"https://api.github.com/users/cryode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cryode/subscriptions","organizations_url":"https://api.github.com/users/cryode/orgs","repos_url":"https://api.github.com/users/cryode/repos","events_url":"https://api.github.com/users/cryode/events{/privacy}","received_events_url":"https://api.github.com/users/cryode/received_events","type":"User","site_admin":false},"created_at":"2015-09-17T17:50:58Z","updated_at":"2015-09-17T17:50:58Z","body":"They could be static properties, yes. It's really up to the developer whether or not you want it to be completely static or instantiated (or both for whatever reason).\r\n\r\n> This would contradict the original suggestion to make static factories.\r\n\r\nIt was just a suggestion, same as the code snippet above. More or less an example of how to separate the concerns from the two classes. Whether or not the end implementation is static or not is not up to me. It's not my job to tell another developer how to build their library in minute detail, or I'd just do it myself."}}