{"action":"created","comment":{"url":"https://api.github.com/repos/contao/core-bundle/pulls/comments/39500848","id":39500848,"diff_hunk":"@@ -0,0 +1,81 @@\n+<?php\n+\n+/*\n+ * This file is part of Contao.\n+ *\n+ * Copyright (c) 2005-2015 Leo Feyer\n+ *\n+ * @license LGPL-3.0+\n+ */\n+\n+namespace Contao\\CoreBundle\\Adapter;\n+\n+/**\n+ * A general Adapter class building a wrapper around any class that is not\n+ * Unit testable/mockable. It only delegates method calls to the specified\n+ * class\n+ *\n+ * @author Yanick Witschi <https://github.com/toflar>\n+ *\n+ * @internal\n+ */\n+class Adapter\n+{\n+    /**\n+     * Class name.\n+     *\n+     * @var string\n+     */\n+    private $class;\n+\n+    /**\n+     * Constructor arguments.\n+     *\n+     * @var array\n+     */\n+    private $args = [];\n+\n+    /**\n+     * Adapter factory.\n+     *\n+     * @var AdapterFactoryInterface\n+     */\n+    private $factory;\n+\n+    /**\n+     * Adapter constructor.\n+     *\n+     * @param string                    $class\n+     * @param array                     $args Constructor arguments.\n+     * @param AdapterFactoryInterface   $factory\n+     */\n+    public function __construct($class, $args = [], AdapterFactoryInterface $factory)\n+    {\n+        $this->class    = $class;\n+        $this->args     = $args;\n+        $this->factory  = $factory;\n+    }\n+\n+    /**\n+     * Calls any method of the given class.\n+     *\n+     * @param string $name\n+     * @param array  $arguments\n+     *\n+     * @return mixed\n+     */\n+    public function __call($name, array $arguments = [])\n+    {\n+        $method = new \\ReflectionMethod($this->class, $name);\n+        $method->setAccessible(true);\n+\n+        if ($method->isStatic()) {\n+\n+            return $method->invokeArgs(null, $arguments);\n+        }\n+\n+        $instance = $this->factory->createInstance($this->class, $this->args);\n+\n+        return $method->invokeArgs($instance, $arguments);","path":"src/Adapter/Adapter.php","position":79,"original_position":79,"commit_id":"832e23649f02cc070f4527e99694e90c3ce1fb2a","original_commit_id":"832e23649f02cc070f4527e99694e90c3ce1fb2a","user":{"login":"aschempp","id":1073273,"avatar_url":"https://avatars.githubusercontent.com/u/1073273?v=3","gravatar_id":"","url":"https://api.github.com/users/aschempp","html_url":"https://github.com/aschempp","followers_url":"https://api.github.com/users/aschempp/followers","following_url":"https://api.github.com/users/aschempp/following{/other_user}","gists_url":"https://api.github.com/users/aschempp/gists{/gist_id}","starred_url":"https://api.github.com/users/aschempp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aschempp/subscriptions","organizations_url":"https://api.github.com/users/aschempp/orgs","repos_url":"https://api.github.com/users/aschempp/repos","events_url":"https://api.github.com/users/aschempp/events{/privacy}","received_events_url":"https://api.github.com/users/aschempp/received_events","type":"User","site_admin":false},"body":"I guess you wanted to use `$instance` here. However, I disagree with the adapter handling non-static methods.","created_at":"2015-09-15T11:50:30Z","updated_at":"2015-09-15T11:50:30Z","html_url":"https://github.com/contao/core-bundle/pull/346#discussion_r39500848","pull_request_url":"https://api.github.com/repos/contao/core-bundle/pulls/346","_links":{"self":{"href":"https://api.github.com/repos/contao/core-bundle/pulls/comments/39500848"},"html":{"href":"https://github.com/contao/core-bundle/pull/346#discussion_r39500848"},"pull_request":{"href":"https://api.github.com/repos/contao/core-bundle/pulls/346"}}},"pull_request":{"url":"https://api.github.com/repos/contao/core-bundle/pulls/346","id":45037649,"html_url":"https://github.com/contao/core-bundle/pull/346","diff_url":"https://github.com/contao/core-bundle/pull/346.diff","patch_url":"https://github.com/contao/core-bundle/pull/346.patch","issue_url":"https://api.github.com/repos/contao/core-bundle/issues/346","number":346,"state":"open","locked":false,"title":"[RFC] Added a general adapter factory","user":{"login":"Toflar","id":481937,"avatar_url":"https://avatars.githubusercontent.com/u/481937?v=3","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"body":"So this is the first attempt for the general adapter factory we discussed last week.\r\n\r\nOpen questions:\r\n* [ ] It is in the nature of things that the adapter classes cannot be tested so I cannot write more unit tests for this, really. How do we ensure it's the way we want it to be before merging it? Should @ausi rebase and use it in his Image PR?\r\n","created_at":"2015-09-15T11:28:33Z","updated_at":"2015-09-15T11:50:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8febc640652b46b91fb48f73ea080a7d13d4e090","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/contao/core-bundle/pulls/346/commits","review_comments_url":"https://api.github.com/repos/contao/core-bundle/pulls/346/comments","review_comment_url":"https://api.github.com/repos/contao/core-bundle/pulls/comments{/number}","comments_url":"https://api.github.com/repos/contao/core-bundle/issues/346/comments","statuses_url":"https://api.github.com/repos/contao/core-bundle/statuses/832e23649f02cc070f4527e99694e90c3ce1fb2a","head":{"label":"Toflar:feature/adapters","ref":"feature/adapters","sha":"832e23649f02cc070f4527e99694e90c3ce1fb2a","user":{"login":"Toflar","id":481937,"avatar_url":"https://avatars.githubusercontent.com/u/481937?v=3","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"repo":{"id":26642166,"name":"core-bundle","full_name":"Toflar/core-bundle","owner":{"login":"Toflar","id":481937,"avatar_url":"https://avatars.githubusercontent.com/u/481937?v=3","gravatar_id":"","url":"https://api.github.com/users/Toflar","html_url":"https://github.com/Toflar","followers_url":"https://api.github.com/users/Toflar/followers","following_url":"https://api.github.com/users/Toflar/following{/other_user}","gists_url":"https://api.github.com/users/Toflar/gists{/gist_id}","starred_url":"https://api.github.com/users/Toflar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Toflar/subscriptions","organizations_url":"https://api.github.com/users/Toflar/orgs","repos_url":"https://api.github.com/users/Toflar/repos","events_url":"https://api.github.com/users/Toflar/events{/privacy}","received_events_url":"https://api.github.com/users/Toflar/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/Toflar/core-bundle","description":"Contao 4 core bundle","fork":true,"url":"https://api.github.com/repos/Toflar/core-bundle","forks_url":"https://api.github.com/repos/Toflar/core-bundle/forks","keys_url":"https://api.github.com/repos/Toflar/core-bundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Toflar/core-bundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Toflar/core-bundle/teams","hooks_url":"https://api.github.com/repos/Toflar/core-bundle/hooks","issue_events_url":"https://api.github.com/repos/Toflar/core-bundle/issues/events{/number}","events_url":"https://api.github.com/repos/Toflar/core-bundle/events","assignees_url":"https://api.github.com/repos/Toflar/core-bundle/assignees{/user}","branches_url":"https://api.github.com/repos/Toflar/core-bundle/branches{/branch}","tags_url":"https://api.github.com/repos/Toflar/core-bundle/tags","blobs_url":"https://api.github.com/repos/Toflar/core-bundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Toflar/core-bundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Toflar/core-bundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/Toflar/core-bundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Toflar/core-bundle/statuses/{sha}","languages_url":"https://api.github.com/repos/Toflar/core-bundle/languages","stargazers_url":"https://api.github.com/repos/Toflar/core-bundle/stargazers","contributors_url":"https://api.github.com/repos/Toflar/core-bundle/contributors","subscribers_url":"https://api.github.com/repos/Toflar/core-bundle/subscribers","subscription_url":"https://api.github.com/repos/Toflar/core-bundle/subscription","commits_url":"https://api.github.com/repos/Toflar/core-bundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/Toflar/core-bundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/Toflar/core-bundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/Toflar/core-bundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/Toflar/core-bundle/contents/{+path}","compare_url":"https://api.github.com/repos/Toflar/core-bundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Toflar/core-bundle/merges","archive_url":"https://api.github.com/repos/Toflar/core-bundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Toflar/core-bundle/downloads","issues_url":"https://api.github.com/repos/Toflar/core-bundle/issues{/number}","pulls_url":"https://api.github.com/repos/Toflar/core-bundle/pulls{/number}","milestones_url":"https://api.github.com/repos/Toflar/core-bundle/milestones{/number}","notifications_url":"https://api.github.com/repos/Toflar/core-bundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Toflar/core-bundle/labels{/name}","releases_url":"https://api.github.com/repos/Toflar/core-bundle/releases{/id}","created_at":"2014-11-14T14:32:10Z","updated_at":"2015-04-18T14:10:14Z","pushed_at":"2015-09-15T11:38:59Z","git_url":"git://github.com/Toflar/core-bundle.git","ssh_url":"git@github.com:Toflar/core-bundle.git","clone_url":"https://github.com/Toflar/core-bundle.git","svn_url":"https://github.com/Toflar/core-bundle","homepage":"","size":23805,"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":"develop"}},"base":{"label":"contao:develop","ref":"develop","sha":"66d380d37b9d9c848f5e33b3e2a6937d6e44d7fd","user":{"login":"contao","id":1206136,"avatar_url":"https://avatars.githubusercontent.com/u/1206136?v=3","gravatar_id":"","url":"https://api.github.com/users/contao","html_url":"https://github.com/contao","followers_url":"https://api.github.com/users/contao/followers","following_url":"https://api.github.com/users/contao/following{/other_user}","gists_url":"https://api.github.com/users/contao/gists{/gist_id}","starred_url":"https://api.github.com/users/contao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contao/subscriptions","organizations_url":"https://api.github.com/users/contao/orgs","repos_url":"https://api.github.com/users/contao/repos","events_url":"https://api.github.com/users/contao/events{/privacy}","received_events_url":"https://api.github.com/users/contao/received_events","type":"Organization","site_admin":false},"repo":{"id":20519851,"name":"core-bundle","full_name":"contao/core-bundle","owner":{"login":"contao","id":1206136,"avatar_url":"https://avatars.githubusercontent.com/u/1206136?v=3","gravatar_id":"","url":"https://api.github.com/users/contao","html_url":"https://github.com/contao","followers_url":"https://api.github.com/users/contao/followers","following_url":"https://api.github.com/users/contao/following{/other_user}","gists_url":"https://api.github.com/users/contao/gists{/gist_id}","starred_url":"https://api.github.com/users/contao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/contao/subscriptions","organizations_url":"https://api.github.com/users/contao/orgs","repos_url":"https://api.github.com/users/contao/repos","events_url":"https://api.github.com/users/contao/events{/privacy}","received_events_url":"https://api.github.com/users/contao/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/contao/core-bundle","description":"Contao 4 core bundle","fork":false,"url":"https://api.github.com/repos/contao/core-bundle","forks_url":"https://api.github.com/repos/contao/core-bundle/forks","keys_url":"https://api.github.com/repos/contao/core-bundle/keys{/key_id}","collaborators_url":"https://api.github.com/repos/contao/core-bundle/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/contao/core-bundle/teams","hooks_url":"https://api.github.com/repos/contao/core-bundle/hooks","issue_events_url":"https://api.github.com/repos/contao/core-bundle/issues/events{/number}","events_url":"https://api.github.com/repos/contao/core-bundle/events","assignees_url":"https://api.github.com/repos/contao/core-bundle/assignees{/user}","branches_url":"https://api.github.com/repos/contao/core-bundle/branches{/branch}","tags_url":"https://api.github.com/repos/contao/core-bundle/tags","blobs_url":"https://api.github.com/repos/contao/core-bundle/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/contao/core-bundle/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/contao/core-bundle/git/refs{/sha}","trees_url":"https://api.github.com/repos/contao/core-bundle/git/trees{/sha}","statuses_url":"https://api.github.com/repos/contao/core-bundle/statuses/{sha}","languages_url":"https://api.github.com/repos/contao/core-bundle/languages","stargazers_url":"https://api.github.com/repos/contao/core-bundle/stargazers","contributors_url":"https://api.github.com/repos/contao/core-bundle/contributors","subscribers_url":"https://api.github.com/repos/contao/core-bundle/subscribers","subscription_url":"https://api.github.com/repos/contao/core-bundle/subscription","commits_url":"https://api.github.com/repos/contao/core-bundle/commits{/sha}","git_commits_url":"https://api.github.com/repos/contao/core-bundle/git/commits{/sha}","comments_url":"https://api.github.com/repos/contao/core-bundle/comments{/number}","issue_comment_url":"https://api.github.com/repos/contao/core-bundle/issues/comments{/number}","contents_url":"https://api.github.com/repos/contao/core-bundle/contents/{+path}","compare_url":"https://api.github.com/repos/contao/core-bundle/compare/{base}...{head}","merges_url":"https://api.github.com/repos/contao/core-bundle/merges","archive_url":"https://api.github.com/repos/contao/core-bundle/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/contao/core-bundle/downloads","issues_url":"https://api.github.com/repos/contao/core-bundle/issues{/number}","pulls_url":"https://api.github.com/repos/contao/core-bundle/pulls{/number}","milestones_url":"https://api.github.com/repos/contao/core-bundle/milestones{/number}","notifications_url":"https://api.github.com/repos/contao/core-bundle/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/contao/core-bundle/labels{/name}","releases_url":"https://api.github.com/repos/contao/core-bundle/releases{/id}","created_at":"2014-06-05T09:45:55Z","updated_at":"2015-08-27T09:04:01Z","pushed_at":"2015-09-15T11:38:59Z","git_url":"git://github.com/contao/core-bundle.git","ssh_url":"git@github.com:contao/core-bundle.git","clone_url":"https://github.com/contao/core-bundle.git","svn_url":"https://github.com/contao/core-bundle","homepage":"","size":29362,"stargazers_count":26,"watchers_count":26,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":11,"mirror_url":null,"open_issues_count":30,"forks":11,"open_issues":30,"watchers":26,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/contao/core-bundle/pulls/346"},"html":{"href":"https://github.com/contao/core-bundle/pull/346"},"issue":{"href":"https://api.github.com/repos/contao/core-bundle/issues/346"},"comments":{"href":"https://api.github.com/repos/contao/core-bundle/issues/346/comments"},"review_comments":{"href":"https://api.github.com/repos/contao/core-bundle/pulls/346/comments"},"review_comment":{"href":"https://api.github.com/repos/contao/core-bundle/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/contao/core-bundle/pulls/346/commits"},"statuses":{"href":"https://api.github.com/repos/contao/core-bundle/statuses/832e23649f02cc070f4527e99694e90c3ce1fb2a"}}}}