{"action":"created","comment":{"url":"https://api.github.com/repos/simpspector/analyser/pulls/comments/32896119","id":32896119,"diff_hunk":"@@ -0,0 +1,113 @@\n+<?php\n+\n+namespace SimpSpector\\Analyser\\Gadget;\n+\n+use SimpSpector\\Analyser\\Issue;\n+use SimpSpector\\Analyser\\Logger\\AbstractLogger;\n+use SimpSpector\\Analyser\\Metric;\n+use SimpSpector\\Analyser\\Process\\ProcessBuilder;\n+use SimpSpector\\Analyser\\Result;\n+use Symfony\\Component\\Config\\Definition\\Builder\\ArrayNodeDefinition;\n+use Symfony\\Component\\Filesystem\\Filesystem;\n+use Symfony\\Component\\Serializer\\Encoder\\XmlEncoder;\n+\n+/**\n+ * @author David Badura <d.a.badura@gmail.com>\n+ */\n+class PdependGadget implements GadgetInterface\n+{\n+    /**\n+     * @var string\n+     */\n+    private $bin;\n+\n+    /**\n+     * @param string $bin\n+     */\n+    public function __construct($bin = 'pdepend')\n+    {\n+        $this->bin = $bin;\n+    }\n+\n+    /**\n+     * @param ArrayNodeDefinition $node\n+     */\n+    public function configure(ArrayNodeDefinition $node)\n+    {\n+        $node->children()\n+            ->node('files', 'paths')->defaultValue(['./'])->end()\n+            ->end();\n+    }\n+\n+    /**\n+     * @param string $path\n+     * @param array $options\n+     * @param AbstractLogger $logger\n+     * @return Result\n+     */\n+    public function run($path, array $options, AbstractLogger $logger)\n+    {\n+        $file = tempnam('/tmp', 'pdepend_');\n+\n+        $processBuilder = new ProcessBuilder([$this->bin]);\n+        $processBuilder->add('--summary-xml=' . $file);\n+        $processBuilder->add(implode(',', $options['files']));\n+        $processBuilder->setWorkingDirectory($path);\n+        $processBuilder->run($logger);\n+\n+        $data = $this->convertFromXmlToArray(file_get_contents($file));\n+\n+        (new Filesystem())->remove($file);\n+\n+        $result = new Result();\n+\n+        $add = function ($code, $title, $description = null) use ($result, $data) {","path":"src/Gadget/PdependGadget.php","position":64,"original_position":64,"commit_id":"8c9b5ac35aa246f288edb7a0c67c0e355b430da8","original_commit_id":"8c9b5ac35aa246f288edb7a0c67c0e355b430da8","user":{"login":"tolry","id":259744,"avatar_url":"https://avatars.githubusercontent.com/u/259744?v=3","gravatar_id":"","url":"https://api.github.com/users/tolry","html_url":"https://github.com/tolry","followers_url":"https://api.github.com/users/tolry/followers","following_url":"https://api.github.com/users/tolry/following{/other_user}","gists_url":"https://api.github.com/users/tolry/gists{/gist_id}","starred_url":"https://api.github.com/users/tolry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tolry/subscriptions","organizations_url":"https://api.github.com/users/tolry/orgs","repos_url":"https://api.github.com/users/tolry/repos","events_url":"https://api.github.com/users/tolry/events{/privacy}","received_events_url":"https://api.github.com/users/tolry/received_events","type":"User","site_admin":false},"body":"because we can :wink:\r\n\r\nI am fine with this solution, but the argument that you won't have to pass as many arguments doesn't quite fit in this case. you might as well have taken an array instead of the  `$add(...)` calls and put the function code below in a loop. The complexity would have been the same and you wouldn't have to pass anything around, since you remain in the same method.\r\n\r\nBut I still like it, because this function is very specific to the method where its declared in. It makes sense to make it inaccessible to any other methods, even those in the same class.","created_at":"2015-06-21T18:49:40Z","updated_at":"2015-06-21T18:49:40Z","html_url":"https://github.com/simpspector/analyser/pull/52#discussion_r32896119","pull_request_url":"https://api.github.com/repos/simpspector/analyser/pulls/52","_links":{"self":{"href":"https://api.github.com/repos/simpspector/analyser/pulls/comments/32896119"},"html":{"href":"https://github.com/simpspector/analyser/pull/52#discussion_r32896119"},"pull_request":{"href":"https://api.github.com/repos/simpspector/analyser/pulls/52"}}},"pull_request":{"url":"https://api.github.com/repos/simpspector/analyser/pulls/52","id":38186142,"html_url":"https://github.com/simpspector/analyser/pull/52","diff_url":"https://github.com/simpspector/analyser/pull/52.diff","patch_url":"https://github.com/simpspector/analyser/pull/52.patch","issue_url":"https://api.github.com/repos/simpspector/analyser/issues/52","number":52,"state":"open","locked":false,"title":"[gadget] pdepend","user":{"login":"DavidBadura","id":470138,"avatar_url":"https://avatars.githubusercontent.com/u/470138?v=3","gravatar_id":"","url":"https://api.github.com/users/DavidBadura","html_url":"https://github.com/DavidBadura","followers_url":"https://api.github.com/users/DavidBadura/followers","following_url":"https://api.github.com/users/DavidBadura/following{/other_user}","gists_url":"https://api.github.com/users/DavidBadura/gists{/gist_id}","starred_url":"https://api.github.com/users/DavidBadura/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DavidBadura/subscriptions","organizations_url":"https://api.github.com/users/DavidBadura/orgs","repos_url":"https://api.github.com/users/DavidBadura/repos","events_url":"https://api.github.com/users/DavidBadura/events{/privacy}","received_events_url":"https://api.github.com/users/DavidBadura/received_events","type":"User","site_admin":false},"body":"fixes #30 ","created_at":"2015-06-21T15:47:50Z","updated_at":"2015-06-21T18:49:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"7def0241540bc7598206a61d950c53d9f36e1f61","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/simpspector/analyser/pulls/52/commits","review_comments_url":"https://api.github.com/repos/simpspector/analyser/pulls/52/comments","review_comment_url":"https://api.github.com/repos/simpspector/analyser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/simpspector/analyser/issues/52/comments","statuses_url":"https://api.github.com/repos/simpspector/analyser/statuses/8c9b5ac35aa246f288edb7a0c67c0e355b430da8","head":{"label":"simpspector:pdepend","ref":"pdepend","sha":"8c9b5ac35aa246f288edb7a0c67c0e355b430da8","user":{"login":"simpspector","id":11267955,"avatar_url":"https://avatars.githubusercontent.com/u/11267955?v=3","gravatar_id":"","url":"https://api.github.com/users/simpspector","html_url":"https://github.com/simpspector","followers_url":"https://api.github.com/users/simpspector/followers","following_url":"https://api.github.com/users/simpspector/following{/other_user}","gists_url":"https://api.github.com/users/simpspector/gists{/gist_id}","starred_url":"https://api.github.com/users/simpspector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpspector/subscriptions","organizations_url":"https://api.github.com/users/simpspector/orgs","repos_url":"https://api.github.com/users/simpspector/repos","events_url":"https://api.github.com/users/simpspector/events{/privacy}","received_events_url":"https://api.github.com/users/simpspector/received_events","type":"Organization","site_admin":false},"repo":{"id":30931414,"name":"analyser","full_name":"simpspector/analyser","owner":{"login":"simpspector","id":11267955,"avatar_url":"https://avatars.githubusercontent.com/u/11267955?v=3","gravatar_id":"","url":"https://api.github.com/users/simpspector","html_url":"https://github.com/simpspector","followers_url":"https://api.github.com/users/simpspector/followers","following_url":"https://api.github.com/users/simpspector/following{/other_user}","gists_url":"https://api.github.com/users/simpspector/gists{/gist_id}","starred_url":"https://api.github.com/users/simpspector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpspector/subscriptions","organizations_url":"https://api.github.com/users/simpspector/orgs","repos_url":"https://api.github.com/users/simpspector/repos","events_url":"https://api.github.com/users/simpspector/events{/privacy}","received_events_url":"https://api.github.com/users/simpspector/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simpspector/analyser","description":"this is the analyser component to simpspector/simpspector - all the static code inspection is done here","fork":false,"url":"https://api.github.com/repos/simpspector/analyser","forks_url":"https://api.github.com/repos/simpspector/analyser/forks","keys_url":"https://api.github.com/repos/simpspector/analyser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simpspector/analyser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simpspector/analyser/teams","hooks_url":"https://api.github.com/repos/simpspector/analyser/hooks","issue_events_url":"https://api.github.com/repos/simpspector/analyser/issues/events{/number}","events_url":"https://api.github.com/repos/simpspector/analyser/events","assignees_url":"https://api.github.com/repos/simpspector/analyser/assignees{/user}","branches_url":"https://api.github.com/repos/simpspector/analyser/branches{/branch}","tags_url":"https://api.github.com/repos/simpspector/analyser/tags","blobs_url":"https://api.github.com/repos/simpspector/analyser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simpspector/analyser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simpspector/analyser/git/refs{/sha}","trees_url":"https://api.github.com/repos/simpspector/analyser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simpspector/analyser/statuses/{sha}","languages_url":"https://api.github.com/repos/simpspector/analyser/languages","stargazers_url":"https://api.github.com/repos/simpspector/analyser/stargazers","contributors_url":"https://api.github.com/repos/simpspector/analyser/contributors","subscribers_url":"https://api.github.com/repos/simpspector/analyser/subscribers","subscription_url":"https://api.github.com/repos/simpspector/analyser/subscription","commits_url":"https://api.github.com/repos/simpspector/analyser/commits{/sha}","git_commits_url":"https://api.github.com/repos/simpspector/analyser/git/commits{/sha}","comments_url":"https://api.github.com/repos/simpspector/analyser/comments{/number}","issue_comment_url":"https://api.github.com/repos/simpspector/analyser/issues/comments{/number}","contents_url":"https://api.github.com/repos/simpspector/analyser/contents/{+path}","compare_url":"https://api.github.com/repos/simpspector/analyser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simpspector/analyser/merges","archive_url":"https://api.github.com/repos/simpspector/analyser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simpspector/analyser/downloads","issues_url":"https://api.github.com/repos/simpspector/analyser/issues{/number}","pulls_url":"https://api.github.com/repos/simpspector/analyser/pulls{/number}","milestones_url":"https://api.github.com/repos/simpspector/analyser/milestones{/number}","notifications_url":"https://api.github.com/repos/simpspector/analyser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simpspector/analyser/labels{/name}","releases_url":"https://api.github.com/repos/simpspector/analyser/releases{/id}","created_at":"2015-02-17T18:40:04Z","updated_at":"2015-03-30T11:44:09Z","pushed_at":"2015-06-21T15:49:44Z","git_url":"git://github.com/simpspector/analyser.git","ssh_url":"git@github.com:simpspector/analyser.git","clone_url":"https://github.com/simpspector/analyser.git","svn_url":"https://github.com/simpspector/analyser","homepage":"","size":688,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":21,"forks":0,"open_issues":21,"watchers":2,"default_branch":"master"}},"base":{"label":"simpspector:master","ref":"master","sha":"a6cc8ae46fbe6b93e638d9177cf48ff450c566d4","user":{"login":"simpspector","id":11267955,"avatar_url":"https://avatars.githubusercontent.com/u/11267955?v=3","gravatar_id":"","url":"https://api.github.com/users/simpspector","html_url":"https://github.com/simpspector","followers_url":"https://api.github.com/users/simpspector/followers","following_url":"https://api.github.com/users/simpspector/following{/other_user}","gists_url":"https://api.github.com/users/simpspector/gists{/gist_id}","starred_url":"https://api.github.com/users/simpspector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpspector/subscriptions","organizations_url":"https://api.github.com/users/simpspector/orgs","repos_url":"https://api.github.com/users/simpspector/repos","events_url":"https://api.github.com/users/simpspector/events{/privacy}","received_events_url":"https://api.github.com/users/simpspector/received_events","type":"Organization","site_admin":false},"repo":{"id":30931414,"name":"analyser","full_name":"simpspector/analyser","owner":{"login":"simpspector","id":11267955,"avatar_url":"https://avatars.githubusercontent.com/u/11267955?v=3","gravatar_id":"","url":"https://api.github.com/users/simpspector","html_url":"https://github.com/simpspector","followers_url":"https://api.github.com/users/simpspector/followers","following_url":"https://api.github.com/users/simpspector/following{/other_user}","gists_url":"https://api.github.com/users/simpspector/gists{/gist_id}","starred_url":"https://api.github.com/users/simpspector/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/simpspector/subscriptions","organizations_url":"https://api.github.com/users/simpspector/orgs","repos_url":"https://api.github.com/users/simpspector/repos","events_url":"https://api.github.com/users/simpspector/events{/privacy}","received_events_url":"https://api.github.com/users/simpspector/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/simpspector/analyser","description":"this is the analyser component to simpspector/simpspector - all the static code inspection is done here","fork":false,"url":"https://api.github.com/repos/simpspector/analyser","forks_url":"https://api.github.com/repos/simpspector/analyser/forks","keys_url":"https://api.github.com/repos/simpspector/analyser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/simpspector/analyser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/simpspector/analyser/teams","hooks_url":"https://api.github.com/repos/simpspector/analyser/hooks","issue_events_url":"https://api.github.com/repos/simpspector/analyser/issues/events{/number}","events_url":"https://api.github.com/repos/simpspector/analyser/events","assignees_url":"https://api.github.com/repos/simpspector/analyser/assignees{/user}","branches_url":"https://api.github.com/repos/simpspector/analyser/branches{/branch}","tags_url":"https://api.github.com/repos/simpspector/analyser/tags","blobs_url":"https://api.github.com/repos/simpspector/analyser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/simpspector/analyser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/simpspector/analyser/git/refs{/sha}","trees_url":"https://api.github.com/repos/simpspector/analyser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/simpspector/analyser/statuses/{sha}","languages_url":"https://api.github.com/repos/simpspector/analyser/languages","stargazers_url":"https://api.github.com/repos/simpspector/analyser/stargazers","contributors_url":"https://api.github.com/repos/simpspector/analyser/contributors","subscribers_url":"https://api.github.com/repos/simpspector/analyser/subscribers","subscription_url":"https://api.github.com/repos/simpspector/analyser/subscription","commits_url":"https://api.github.com/repos/simpspector/analyser/commits{/sha}","git_commits_url":"https://api.github.com/repos/simpspector/analyser/git/commits{/sha}","comments_url":"https://api.github.com/repos/simpspector/analyser/comments{/number}","issue_comment_url":"https://api.github.com/repos/simpspector/analyser/issues/comments{/number}","contents_url":"https://api.github.com/repos/simpspector/analyser/contents/{+path}","compare_url":"https://api.github.com/repos/simpspector/analyser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/simpspector/analyser/merges","archive_url":"https://api.github.com/repos/simpspector/analyser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/simpspector/analyser/downloads","issues_url":"https://api.github.com/repos/simpspector/analyser/issues{/number}","pulls_url":"https://api.github.com/repos/simpspector/analyser/pulls{/number}","milestones_url":"https://api.github.com/repos/simpspector/analyser/milestones{/number}","notifications_url":"https://api.github.com/repos/simpspector/analyser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/simpspector/analyser/labels{/name}","releases_url":"https://api.github.com/repos/simpspector/analyser/releases{/id}","created_at":"2015-02-17T18:40:04Z","updated_at":"2015-03-30T11:44:09Z","pushed_at":"2015-06-21T15:49:44Z","git_url":"git://github.com/simpspector/analyser.git","ssh_url":"git@github.com:simpspector/analyser.git","clone_url":"https://github.com/simpspector/analyser.git","svn_url":"https://github.com/simpspector/analyser","homepage":"","size":688,"stargazers_count":2,"watchers_count":2,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":21,"forks":0,"open_issues":21,"watchers":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/simpspector/analyser/pulls/52"},"html":{"href":"https://github.com/simpspector/analyser/pull/52"},"issue":{"href":"https://api.github.com/repos/simpspector/analyser/issues/52"},"comments":{"href":"https://api.github.com/repos/simpspector/analyser/issues/52/comments"},"review_comments":{"href":"https://api.github.com/repos/simpspector/analyser/pulls/52/comments"},"review_comment":{"href":"https://api.github.com/repos/simpspector/analyser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/simpspector/analyser/pulls/52/commits"},"statuses":{"href":"https://api.github.com/repos/simpspector/analyser/statuses/8c9b5ac35aa246f288edb7a0c67c0e355b430da8"}}}}