{"action":"created","comment":{"url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/comments/39646440","id":39646440,"diff_hunk":"@@ -393,4 +396,82 @@ protected function performProtectedCheck($item)\n             throw new ModifyingProtectedValueException(\"Cannot access $item because it is protected\");\n         }\n     }\n+\n+    /**\n+     * Hydrate with external data\n+     *\n+     * @param $type  string    The type of data to be hydrated into the manager\n+     * @param $data string     The data to be hydrated into the manager\n+     * @return $this\n+     * @throws \\Michaels\\Manager\\Exceptions\\SerializationTypeNotSupportedException\n+     */\n+    public function hydrateFrom($type, $data)\n+    {\n+        // we can possibly do some polymorphism for any other serialization types later\n+        if($type !== 'json'){\n+            throw new SerializationTypeNotSupportedException(\"$type serialization is not supported.\");\n+        }\n+\n+        $decodedData = $this->decodeToJson($data);\n+\n+        if ($this->isJson($decodedData)){\n+\n+            $this->reset($decodedData);\n+            return $this;\n+        }\n+        throw new IncorrectDataException(\"The data is not proper JSON\");\n+    }\n+\n+    /**\n+     * Hydrate with external data, appending to current data\n+     *\n+     * @param $type  string    The type of data to be hydrated into the manager\n+     * @param $data string     The data to be hydrated into the manager\n+     * @return $this\n+     * @throws \\Michaels\\Manager\\Exceptions\\SerializationTypeNotSupportedException\n+     *\n+     */\n+    public function appendFrom($type, $data)\n+    {\n+        if($type !== 'json'){\n+            throw new SerializationTypeNotSupportedException(\"$type serialization is not supported.\");\n+        }\n+\n+        $decodedData = $this->decodeToJson($data);\n+\n+        if ($this->isJson($decodedData)){\n+\n+            $this->add($decodedData);\n+            return $this;\n+        }\n+        throw new IncorrectDataException(\"The data is not proper JSON\");\n+    }\n+\n+    /**\n+     * Checks if the input is really a json string\n+     * @param $data mixed|null\n+     * @return bool\n+     */\n+    private function isJson($data)\n+    {\n+\n+        if ($data !== \"\") {\n+            return (json_last_error() === JSON_ERROR_NONE);\n+        }\n+    }\n+\n+    /**\n+     * Decodes JSON data to array\n+     * @param $data string\n+     * @return mixed|null\n+     */\n+    private function decodeToJson($data)","path":"src/Traits/ManagesItemsTrait.php","position":83,"original_position":83,"commit_id":"38b0561e684b8bc7ad416fd2bf7dc31575a82b2e","original_commit_id":"38b0561e684b8bc7ad416fd2bf7dc31575a82b2e","user":{"login":"chrismichaels84","id":5412413,"avatar_url":"https://avatars.githubusercontent.com/u/5412413?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismichaels84","html_url":"https://github.com/chrismichaels84","followers_url":"https://api.github.com/users/chrismichaels84/followers","following_url":"https://api.github.com/users/chrismichaels84/following{/other_user}","gists_url":"https://api.github.com/users/chrismichaels84/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismichaels84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismichaels84/subscriptions","organizations_url":"https://api.github.com/users/chrismichaels84/orgs","repos_url":"https://api.github.com/users/chrismichaels84/repos","events_url":"https://api.github.com/users/chrismichaels84/events{/privacy}","received_events_url":"https://api.github.com/users/chrismichaels84/received_events","type":"User","site_admin":false},"body":"What about `decodeFromJson()`? We aren't actually turning data into json.","created_at":"2015-09-16T15:42:28Z","updated_at":"2015-09-16T15:42:28Z","html_url":"https://github.com/chrismichaels84/data-manager/pull/26#discussion_r39646440","pull_request_url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/comments/39646440"},"html":{"href":"https://github.com/chrismichaels84/data-manager/pull/26#discussion_r39646440"},"pull_request":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26","id":45132287,"html_url":"https://github.com/chrismichaels84/data-manager/pull/26","diff_url":"https://github.com/chrismichaels84/data-manager/pull/26.diff","patch_url":"https://github.com/chrismichaels84/data-manager/pull/26.patch","issue_url":"https://api.github.com/repos/chrismichaels84/data-manager/issues/26","number":26,"state":"open","locked":false,"title":"Added hydrateFrom() and appendFrom() methods","user":{"login":"smolinari","id":3314957,"avatar_url":"https://avatars.githubusercontent.com/u/3314957?v=3","gravatar_id":"","url":"https://api.github.com/users/smolinari","html_url":"https://github.com/smolinari","followers_url":"https://api.github.com/users/smolinari/followers","following_url":"https://api.github.com/users/smolinari/following{/other_user}","gists_url":"https://api.github.com/users/smolinari/gists{/gist_id}","starred_url":"https://api.github.com/users/smolinari/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smolinari/subscriptions","organizations_url":"https://api.github.com/users/smolinari/orgs","repos_url":"https://api.github.com/users/smolinari/repos","events_url":"https://api.github.com/users/smolinari/events{/privacy}","received_events_url":"https://api.github.com/users/smolinari/received_events","type":"User","site_admin":false},"body":"Hope this is ok. \r\n\r\nScott","created_at":"2015-09-16T05:21:24Z","updated_at":"2015-09-16T15:42:28Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d6eba2794a52a51e337fa000664bcfba33bb04bd","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26/commits","review_comments_url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26/comments","review_comment_url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chrismichaels84/data-manager/issues/26/comments","statuses_url":"https://api.github.com/repos/chrismichaels84/data-manager/statuses/38b0561e684b8bc7ad416fd2bf7dc31575a82b2e","head":{"label":"SkooppaOS:develop","ref":"develop","sha":"38b0561e684b8bc7ad416fd2bf7dc31575a82b2e","user":{"login":"SkooppaOS","id":10204822,"avatar_url":"https://avatars.githubusercontent.com/u/10204822?v=3","gravatar_id":"","url":"https://api.github.com/users/SkooppaOS","html_url":"https://github.com/SkooppaOS","followers_url":"https://api.github.com/users/SkooppaOS/followers","following_url":"https://api.github.com/users/SkooppaOS/following{/other_user}","gists_url":"https://api.github.com/users/SkooppaOS/gists{/gist_id}","starred_url":"https://api.github.com/users/SkooppaOS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SkooppaOS/subscriptions","organizations_url":"https://api.github.com/users/SkooppaOS/orgs","repos_url":"https://api.github.com/users/SkooppaOS/repos","events_url":"https://api.github.com/users/SkooppaOS/events{/privacy}","received_events_url":"https://api.github.com/users/SkooppaOS/received_events","type":"Organization","site_admin":false},"repo":{"id":42460638,"name":"data-manager","full_name":"SkooppaOS/data-manager","owner":{"login":"SkooppaOS","id":10204822,"avatar_url":"https://avatars.githubusercontent.com/u/10204822?v=3","gravatar_id":"","url":"https://api.github.com/users/SkooppaOS","html_url":"https://github.com/SkooppaOS","followers_url":"https://api.github.com/users/SkooppaOS/followers","following_url":"https://api.github.com/users/SkooppaOS/following{/other_user}","gists_url":"https://api.github.com/users/SkooppaOS/gists{/gist_id}","starred_url":"https://api.github.com/users/SkooppaOS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SkooppaOS/subscriptions","organizations_url":"https://api.github.com/users/SkooppaOS/orgs","repos_url":"https://api.github.com/users/SkooppaOS/repos","events_url":"https://api.github.com/users/SkooppaOS/events{/privacy}","received_events_url":"https://api.github.com/users/SkooppaOS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SkooppaOS/data-manager","description":"Simple data manager for nested data and dot notation access","fork":true,"url":"https://api.github.com/repos/SkooppaOS/data-manager","forks_url":"https://api.github.com/repos/SkooppaOS/data-manager/forks","keys_url":"https://api.github.com/repos/SkooppaOS/data-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SkooppaOS/data-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SkooppaOS/data-manager/teams","hooks_url":"https://api.github.com/repos/SkooppaOS/data-manager/hooks","issue_events_url":"https://api.github.com/repos/SkooppaOS/data-manager/issues/events{/number}","events_url":"https://api.github.com/repos/SkooppaOS/data-manager/events","assignees_url":"https://api.github.com/repos/SkooppaOS/data-manager/assignees{/user}","branches_url":"https://api.github.com/repos/SkooppaOS/data-manager/branches{/branch}","tags_url":"https://api.github.com/repos/SkooppaOS/data-manager/tags","blobs_url":"https://api.github.com/repos/SkooppaOS/data-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SkooppaOS/data-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SkooppaOS/data-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/SkooppaOS/data-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SkooppaOS/data-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/SkooppaOS/data-manager/languages","stargazers_url":"https://api.github.com/repos/SkooppaOS/data-manager/stargazers","contributors_url":"https://api.github.com/repos/SkooppaOS/data-manager/contributors","subscribers_url":"https://api.github.com/repos/SkooppaOS/data-manager/subscribers","subscription_url":"https://api.github.com/repos/SkooppaOS/data-manager/subscription","commits_url":"https://api.github.com/repos/SkooppaOS/data-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/SkooppaOS/data-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/SkooppaOS/data-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/SkooppaOS/data-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/SkooppaOS/data-manager/contents/{+path}","compare_url":"https://api.github.com/repos/SkooppaOS/data-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SkooppaOS/data-manager/merges","archive_url":"https://api.github.com/repos/SkooppaOS/data-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SkooppaOS/data-manager/downloads","issues_url":"https://api.github.com/repos/SkooppaOS/data-manager/issues{/number}","pulls_url":"https://api.github.com/repos/SkooppaOS/data-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/SkooppaOS/data-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/SkooppaOS/data-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SkooppaOS/data-manager/labels{/name}","releases_url":"https://api.github.com/repos/SkooppaOS/data-manager/releases{/id}","created_at":"2015-09-14T16:15:29Z","updated_at":"2015-09-14T16:15:30Z","pushed_at":"2015-09-16T07:29:31Z","git_url":"git://github.com/SkooppaOS/data-manager.git","ssh_url":"git@github.com:SkooppaOS/data-manager.git","clone_url":"https://github.com/SkooppaOS/data-manager.git","svn_url":"https://github.com/SkooppaOS/data-manager","homepage":"","size":556,"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":"chrismichaels84:develop","ref":"develop","sha":"cab3c1df67fe84c88660cb0ec7f3e56c28af3421","user":{"login":"chrismichaels84","id":5412413,"avatar_url":"https://avatars.githubusercontent.com/u/5412413?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismichaels84","html_url":"https://github.com/chrismichaels84","followers_url":"https://api.github.com/users/chrismichaels84/followers","following_url":"https://api.github.com/users/chrismichaels84/following{/other_user}","gists_url":"https://api.github.com/users/chrismichaels84/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismichaels84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismichaels84/subscriptions","organizations_url":"https://api.github.com/users/chrismichaels84/orgs","repos_url":"https://api.github.com/users/chrismichaels84/repos","events_url":"https://api.github.com/users/chrismichaels84/events{/privacy}","received_events_url":"https://api.github.com/users/chrismichaels84/received_events","type":"User","site_admin":false},"repo":{"id":33393848,"name":"data-manager","full_name":"chrismichaels84/data-manager","owner":{"login":"chrismichaels84","id":5412413,"avatar_url":"https://avatars.githubusercontent.com/u/5412413?v=3","gravatar_id":"","url":"https://api.github.com/users/chrismichaels84","html_url":"https://github.com/chrismichaels84","followers_url":"https://api.github.com/users/chrismichaels84/followers","following_url":"https://api.github.com/users/chrismichaels84/following{/other_user}","gists_url":"https://api.github.com/users/chrismichaels84/gists{/gist_id}","starred_url":"https://api.github.com/users/chrismichaels84/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chrismichaels84/subscriptions","organizations_url":"https://api.github.com/users/chrismichaels84/orgs","repos_url":"https://api.github.com/users/chrismichaels84/repos","events_url":"https://api.github.com/users/chrismichaels84/events{/privacy}","received_events_url":"https://api.github.com/users/chrismichaels84/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/chrismichaels84/data-manager","description":"Simple data manager for nested data and dot notation access","fork":false,"url":"https://api.github.com/repos/chrismichaels84/data-manager","forks_url":"https://api.github.com/repos/chrismichaels84/data-manager/forks","keys_url":"https://api.github.com/repos/chrismichaels84/data-manager/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chrismichaels84/data-manager/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chrismichaels84/data-manager/teams","hooks_url":"https://api.github.com/repos/chrismichaels84/data-manager/hooks","issue_events_url":"https://api.github.com/repos/chrismichaels84/data-manager/issues/events{/number}","events_url":"https://api.github.com/repos/chrismichaels84/data-manager/events","assignees_url":"https://api.github.com/repos/chrismichaels84/data-manager/assignees{/user}","branches_url":"https://api.github.com/repos/chrismichaels84/data-manager/branches{/branch}","tags_url":"https://api.github.com/repos/chrismichaels84/data-manager/tags","blobs_url":"https://api.github.com/repos/chrismichaels84/data-manager/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chrismichaels84/data-manager/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chrismichaels84/data-manager/git/refs{/sha}","trees_url":"https://api.github.com/repos/chrismichaels84/data-manager/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chrismichaels84/data-manager/statuses/{sha}","languages_url":"https://api.github.com/repos/chrismichaels84/data-manager/languages","stargazers_url":"https://api.github.com/repos/chrismichaels84/data-manager/stargazers","contributors_url":"https://api.github.com/repos/chrismichaels84/data-manager/contributors","subscribers_url":"https://api.github.com/repos/chrismichaels84/data-manager/subscribers","subscription_url":"https://api.github.com/repos/chrismichaels84/data-manager/subscription","commits_url":"https://api.github.com/repos/chrismichaels84/data-manager/commits{/sha}","git_commits_url":"https://api.github.com/repos/chrismichaels84/data-manager/git/commits{/sha}","comments_url":"https://api.github.com/repos/chrismichaels84/data-manager/comments{/number}","issue_comment_url":"https://api.github.com/repos/chrismichaels84/data-manager/issues/comments{/number}","contents_url":"https://api.github.com/repos/chrismichaels84/data-manager/contents/{+path}","compare_url":"https://api.github.com/repos/chrismichaels84/data-manager/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chrismichaels84/data-manager/merges","archive_url":"https://api.github.com/repos/chrismichaels84/data-manager/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chrismichaels84/data-manager/downloads","issues_url":"https://api.github.com/repos/chrismichaels84/data-manager/issues{/number}","pulls_url":"https://api.github.com/repos/chrismichaels84/data-manager/pulls{/number}","milestones_url":"https://api.github.com/repos/chrismichaels84/data-manager/milestones{/number}","notifications_url":"https://api.github.com/repos/chrismichaels84/data-manager/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chrismichaels84/data-manager/labels{/name}","releases_url":"https://api.github.com/repos/chrismichaels84/data-manager/releases{/id}","created_at":"2015-04-04T04:10:45Z","updated_at":"2015-09-12T18:23:01Z","pushed_at":"2015-09-16T07:29:32Z","git_url":"git://github.com/chrismichaels84/data-manager.git","ssh_url":"git@github.com:chrismichaels84/data-manager.git","clone_url":"https://github.com/chrismichaels84/data-manager.git","svn_url":"https://github.com/chrismichaels84/data-manager","homepage":"","size":556,"stargazers_count":5,"watchers_count":5,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":7,"forks":1,"open_issues":7,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26"},"html":{"href":"https://github.com/chrismichaels84/data-manager/pull/26"},"issue":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/issues/26"},"comments":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/chrismichaels84/data-manager/statuses/38b0561e684b8bc7ad416fd2bf7dc31575a82b2e"}}}}