{"action":"created","comment":{"url":"https://api.github.com/repos/jameshalsall/licenser/pulls/comments/40223064","id":40223064,"diff_hunk":"@@ -210,4 +194,83 @@ private function log($message)\n \n         $this->output->writeln($message);\n     }\n+\n+    /**\n+     * @param string  $path The path to the files/directory\n+     */\n+    public function check($path)\n+    {\n+        foreach ( $this->getFiles($path) as $file) {\n+            $this->checkFile($file);\n+        }\n+    }\n+\n+    /**\n+     * Checks the header of 1 file\n+     * @param SplFileInfo $file\n+     */\n+    private function checkFile(SplFileInfo $file)\n+    {\n+        $tokens = token_get_all($file->getContents());\n+        $licenseTokenIndex = $this->getLicensetokenIndex($tokens);\n+\n+        if ($licenseTokenIndex === null) {\n+            $this->log(sprintf('Missing license header in \"%s\"', $file->getRealPath()));\n+        } elseif ($tokens[$licenseTokenIndex][1] != $this->getLicenseAsComment()) {\n+            $this->log(sprintf('Different license header in \"%s\"', $file->getRealPath()));\n+        }\n+    }\n+\n+    /**\n+     * @param $path\n+     * @return SplFileInfo[]\n+     */\n+    private function getFiles($path)\n+    {\n+        if (is_file($path)) {\n+            return [new SplFileInfo($path, '', '')];\n+        } else {\n+            $iterator = $this->finder->name('*.php')->in(realpath($path));\n+        }\n+        return $iterator;\n+    }\n+\n+    /**\n+     * returns the index of the first token that is a comment\n+     *\n+     * @param $tokens\n+     * @return int|null the index of the token or null when no comment is found before the class declaration\n+     */\n+    private function getLicensetokenIndex($tokens)\n+    {\n+        $licenseTokenIndex = null;\n+\n+        foreach ($tokens as $index => $token) {\n+            if ($token[0] === T_COMMENT) {\n+                $licenseTokenIndex = $index;\n+            }\n+\n+            // if we reach the class declaration then it does not have a license\n+            if ($token[0] === T_CLASS) {\n+                break;\n+            }\n+        }\n+        return $licenseTokenIndex;","path":"src/JamesHalsall/Licenser/Licenser.php","position":111,"original_position":111,"commit_id":"cba6074be63ed681f586d44d8bb42b4cf20c4f86","original_commit_id":"cba6074be63ed681f586d44d8bb42b4cf20c4f86","user":{"login":"jameshalsall","id":499932,"avatar_url":"https://avatars.githubusercontent.com/u/499932?v=3","gravatar_id":"","url":"https://api.github.com/users/jameshalsall","html_url":"https://github.com/jameshalsall","followers_url":"https://api.github.com/users/jameshalsall/followers","following_url":"https://api.github.com/users/jameshalsall/following{/other_user}","gists_url":"https://api.github.com/users/jameshalsall/gists{/gist_id}","starred_url":"https://api.github.com/users/jameshalsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameshalsall/subscriptions","organizations_url":"https://api.github.com/users/jameshalsall/orgs","repos_url":"https://api.github.com/users/jameshalsall/repos","events_url":"https://api.github.com/users/jameshalsall/events{/privacy}","received_events_url":"https://api.github.com/users/jameshalsall/received_events","type":"User","site_admin":false},"body":"should be a blank line before return statement","created_at":"2015-09-23T16:10:39Z","updated_at":"2015-09-23T16:10:39Z","html_url":"https://github.com/jameshalsall/licenser/pull/6#discussion_r40223064","pull_request_url":"https://api.github.com/repos/jameshalsall/licenser/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/jameshalsall/licenser/pulls/comments/40223064"},"html":{"href":"https://github.com/jameshalsall/licenser/pull/6#discussion_r40223064"},"pull_request":{"href":"https://api.github.com/repos/jameshalsall/licenser/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/jameshalsall/licenser/pulls/6","id":45273754,"html_url":"https://github.com/jameshalsall/licenser/pull/6","diff_url":"https://github.com/jameshalsall/licenser/pull/6.diff","patch_url":"https://github.com/jameshalsall/licenser/pull/6.patch","issue_url":"https://api.github.com/repos/jameshalsall/licenser/issues/6","number":6,"state":"open","locked":false,"title":"Added support for single file and added a check option","user":{"login":"jeroensmit","id":1814884,"avatar_url":"https://avatars.githubusercontent.com/u/1814884?v=3","gravatar_id":"","url":"https://api.github.com/users/jeroensmit","html_url":"https://github.com/jeroensmit","followers_url":"https://api.github.com/users/jeroensmit/followers","following_url":"https://api.github.com/users/jeroensmit/following{/other_user}","gists_url":"https://api.github.com/users/jeroensmit/gists{/gist_id}","starred_url":"https://api.github.com/users/jeroensmit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeroensmit/subscriptions","organizations_url":"https://api.github.com/users/jeroensmit/orgs","repos_url":"https://api.github.com/users/jeroensmit/repos","events_url":"https://api.github.com/users/jeroensmit/events{/privacy}","received_events_url":"https://api.github.com/users/jeroensmit/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-17T10:18:15Z","updated_at":"2015-09-23T16:10:39Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4c981cec7444d21804b4329e2ad066b9a47dee53","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jameshalsall/licenser/pulls/6/commits","review_comments_url":"https://api.github.com/repos/jameshalsall/licenser/pulls/6/comments","review_comment_url":"https://api.github.com/repos/jameshalsall/licenser/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jameshalsall/licenser/issues/6/comments","statuses_url":"https://api.github.com/repos/jameshalsall/licenser/statuses/cba6074be63ed681f586d44d8bb42b4cf20c4f86","head":{"label":"picturae:master","ref":"master","sha":"cba6074be63ed681f586d44d8bb42b4cf20c4f86","user":{"login":"picturae","id":1853781,"avatar_url":"https://avatars.githubusercontent.com/u/1853781?v=3","gravatar_id":"","url":"https://api.github.com/users/picturae","html_url":"https://github.com/picturae","followers_url":"https://api.github.com/users/picturae/followers","following_url":"https://api.github.com/users/picturae/following{/other_user}","gists_url":"https://api.github.com/users/picturae/gists{/gist_id}","starred_url":"https://api.github.com/users/picturae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picturae/subscriptions","organizations_url":"https://api.github.com/users/picturae/orgs","repos_url":"https://api.github.com/users/picturae/repos","events_url":"https://api.github.com/users/picturae/events{/privacy}","received_events_url":"https://api.github.com/users/picturae/received_events","type":"Organization","site_admin":false},"repo":{"id":42648892,"name":"licenser","full_name":"picturae/licenser","owner":{"login":"picturae","id":1853781,"avatar_url":"https://avatars.githubusercontent.com/u/1853781?v=3","gravatar_id":"","url":"https://api.github.com/users/picturae","html_url":"https://github.com/picturae","followers_url":"https://api.github.com/users/picturae/followers","following_url":"https://api.github.com/users/picturae/following{/other_user}","gists_url":"https://api.github.com/users/picturae/gists{/gist_id}","starred_url":"https://api.github.com/users/picturae/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/picturae/subscriptions","organizations_url":"https://api.github.com/users/picturae/orgs","repos_url":"https://api.github.com/users/picturae/repos","events_url":"https://api.github.com/users/picturae/events{/privacy}","received_events_url":"https://api.github.com/users/picturae/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/picturae/licenser","description":"Automatically prepends license headers to your PHP source files","fork":true,"url":"https://api.github.com/repos/picturae/licenser","forks_url":"https://api.github.com/repos/picturae/licenser/forks","keys_url":"https://api.github.com/repos/picturae/licenser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/picturae/licenser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/picturae/licenser/teams","hooks_url":"https://api.github.com/repos/picturae/licenser/hooks","issue_events_url":"https://api.github.com/repos/picturae/licenser/issues/events{/number}","events_url":"https://api.github.com/repos/picturae/licenser/events","assignees_url":"https://api.github.com/repos/picturae/licenser/assignees{/user}","branches_url":"https://api.github.com/repos/picturae/licenser/branches{/branch}","tags_url":"https://api.github.com/repos/picturae/licenser/tags","blobs_url":"https://api.github.com/repos/picturae/licenser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/picturae/licenser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/picturae/licenser/git/refs{/sha}","trees_url":"https://api.github.com/repos/picturae/licenser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/picturae/licenser/statuses/{sha}","languages_url":"https://api.github.com/repos/picturae/licenser/languages","stargazers_url":"https://api.github.com/repos/picturae/licenser/stargazers","contributors_url":"https://api.github.com/repos/picturae/licenser/contributors","subscribers_url":"https://api.github.com/repos/picturae/licenser/subscribers","subscription_url":"https://api.github.com/repos/picturae/licenser/subscription","commits_url":"https://api.github.com/repos/picturae/licenser/commits{/sha}","git_commits_url":"https://api.github.com/repos/picturae/licenser/git/commits{/sha}","comments_url":"https://api.github.com/repos/picturae/licenser/comments{/number}","issue_comment_url":"https://api.github.com/repos/picturae/licenser/issues/comments{/number}","contents_url":"https://api.github.com/repos/picturae/licenser/contents/{+path}","compare_url":"https://api.github.com/repos/picturae/licenser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/picturae/licenser/merges","archive_url":"https://api.github.com/repos/picturae/licenser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/picturae/licenser/downloads","issues_url":"https://api.github.com/repos/picturae/licenser/issues{/number}","pulls_url":"https://api.github.com/repos/picturae/licenser/pulls{/number}","milestones_url":"https://api.github.com/repos/picturae/licenser/milestones{/number}","notifications_url":"https://api.github.com/repos/picturae/licenser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/picturae/licenser/labels{/name}","releases_url":"https://api.github.com/repos/picturae/licenser/releases{/id}","created_at":"2015-09-17T10:03:03Z","updated_at":"2015-09-17T10:03:05Z","pushed_at":"2015-09-17T10:15:25Z","git_url":"git://github.com/picturae/licenser.git","ssh_url":"git@github.com:picturae/licenser.git","clone_url":"https://github.com/picturae/licenser.git","svn_url":"https://github.com/picturae/licenser","homepage":null,"size":116,"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":"master"}},"base":{"label":"jameshalsall:master","ref":"master","sha":"fddeb910d53b9b07a7c8ccfcbd1d6ce62eeb0bef","user":{"login":"jameshalsall","id":499932,"avatar_url":"https://avatars.githubusercontent.com/u/499932?v=3","gravatar_id":"","url":"https://api.github.com/users/jameshalsall","html_url":"https://github.com/jameshalsall","followers_url":"https://api.github.com/users/jameshalsall/followers","following_url":"https://api.github.com/users/jameshalsall/following{/other_user}","gists_url":"https://api.github.com/users/jameshalsall/gists{/gist_id}","starred_url":"https://api.github.com/users/jameshalsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameshalsall/subscriptions","organizations_url":"https://api.github.com/users/jameshalsall/orgs","repos_url":"https://api.github.com/users/jameshalsall/repos","events_url":"https://api.github.com/users/jameshalsall/events{/privacy}","received_events_url":"https://api.github.com/users/jameshalsall/received_events","type":"User","site_admin":false},"repo":{"id":13770829,"name":"licenser","full_name":"jameshalsall/licenser","owner":{"login":"jameshalsall","id":499932,"avatar_url":"https://avatars.githubusercontent.com/u/499932?v=3","gravatar_id":"","url":"https://api.github.com/users/jameshalsall","html_url":"https://github.com/jameshalsall","followers_url":"https://api.github.com/users/jameshalsall/followers","following_url":"https://api.github.com/users/jameshalsall/following{/other_user}","gists_url":"https://api.github.com/users/jameshalsall/gists{/gist_id}","starred_url":"https://api.github.com/users/jameshalsall/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jameshalsall/subscriptions","organizations_url":"https://api.github.com/users/jameshalsall/orgs","repos_url":"https://api.github.com/users/jameshalsall/repos","events_url":"https://api.github.com/users/jameshalsall/events{/privacy}","received_events_url":"https://api.github.com/users/jameshalsall/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jameshalsall/licenser","description":"Automatically prepends license headers to your PHP source files","fork":false,"url":"https://api.github.com/repos/jameshalsall/licenser","forks_url":"https://api.github.com/repos/jameshalsall/licenser/forks","keys_url":"https://api.github.com/repos/jameshalsall/licenser/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jameshalsall/licenser/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jameshalsall/licenser/teams","hooks_url":"https://api.github.com/repos/jameshalsall/licenser/hooks","issue_events_url":"https://api.github.com/repos/jameshalsall/licenser/issues/events{/number}","events_url":"https://api.github.com/repos/jameshalsall/licenser/events","assignees_url":"https://api.github.com/repos/jameshalsall/licenser/assignees{/user}","branches_url":"https://api.github.com/repos/jameshalsall/licenser/branches{/branch}","tags_url":"https://api.github.com/repos/jameshalsall/licenser/tags","blobs_url":"https://api.github.com/repos/jameshalsall/licenser/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jameshalsall/licenser/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jameshalsall/licenser/git/refs{/sha}","trees_url":"https://api.github.com/repos/jameshalsall/licenser/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jameshalsall/licenser/statuses/{sha}","languages_url":"https://api.github.com/repos/jameshalsall/licenser/languages","stargazers_url":"https://api.github.com/repos/jameshalsall/licenser/stargazers","contributors_url":"https://api.github.com/repos/jameshalsall/licenser/contributors","subscribers_url":"https://api.github.com/repos/jameshalsall/licenser/subscribers","subscription_url":"https://api.github.com/repos/jameshalsall/licenser/subscription","commits_url":"https://api.github.com/repos/jameshalsall/licenser/commits{/sha}","git_commits_url":"https://api.github.com/repos/jameshalsall/licenser/git/commits{/sha}","comments_url":"https://api.github.com/repos/jameshalsall/licenser/comments{/number}","issue_comment_url":"https://api.github.com/repos/jameshalsall/licenser/issues/comments{/number}","contents_url":"https://api.github.com/repos/jameshalsall/licenser/contents/{+path}","compare_url":"https://api.github.com/repos/jameshalsall/licenser/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jameshalsall/licenser/merges","archive_url":"https://api.github.com/repos/jameshalsall/licenser/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jameshalsall/licenser/downloads","issues_url":"https://api.github.com/repos/jameshalsall/licenser/issues{/number}","pulls_url":"https://api.github.com/repos/jameshalsall/licenser/pulls{/number}","milestones_url":"https://api.github.com/repos/jameshalsall/licenser/milestones{/number}","notifications_url":"https://api.github.com/repos/jameshalsall/licenser/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jameshalsall/licenser/labels{/name}","releases_url":"https://api.github.com/repos/jameshalsall/licenser/releases{/id}","created_at":"2013-10-22T11:11:08Z","updated_at":"2015-07-02T18:22:56Z","pushed_at":"2015-09-17T10:18:15Z","git_url":"git://github.com/jameshalsall/licenser.git","ssh_url":"git@github.com:jameshalsall/licenser.git","clone_url":"https://github.com/jameshalsall/licenser.git","svn_url":"https://github.com/jameshalsall/licenser","homepage":null,"size":239,"stargazers_count":10,"watchers_count":10,"language":"PHP","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":2,"forks":3,"open_issues":2,"watchers":10,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jameshalsall/licenser/pulls/6"},"html":{"href":"https://github.com/jameshalsall/licenser/pull/6"},"issue":{"href":"https://api.github.com/repos/jameshalsall/licenser/issues/6"},"comments":{"href":"https://api.github.com/repos/jameshalsall/licenser/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/jameshalsall/licenser/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/jameshalsall/licenser/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jameshalsall/licenser/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/jameshalsall/licenser/statuses/cba6074be63ed681f586d44d8bb42b4cf20c4f86"}}}}