@@ -6,7 +6,7 @@ class PHPCS_Diff {
66 private $ phpcs_command = 'phpcs ' ; // You might need to provde a path to phpcs.phar file.
77 private $ standards_location = '~/PHP_CodeSniffer/Standards ' ; // @todo: adjust the path to standards
88
9- private $ diff_parser ;
9+ private $ version_control ;
1010
1111 public $ allowed_extensions ;
1212
@@ -20,11 +20,9 @@ class PHPCS_Diff {
2020
2121 private $ no_diff_to_big = false ;
2222
23- public function __construct () {
23+ public function __construct ( $ version_control ) {
2424
25- require_once ( __DIR__ . 'class-phpcs-diff-svn.php ' );
26-
27- $ this ->diff_parser = new PHPCS_Diff_SVN ( 'hello-dolly ' );
25+ $ this ->version_control = $ version_control ;
2826
2927 $ this ->allowed_extensions = array ( 'php ' , 'js ' );
3028 }
@@ -66,7 +64,7 @@ public function run( $repo, $oldest_rev, $newest_rev ) {
6664 }
6765 }
6866
69- $ diff = trim ( $ this ->diff_parser ->get_diff ( $ repo , $ newest_rev , $ oldest_rev , array ( 'ignore-space-change ' => true ) ) );
67+ $ diff = trim ( $ this ->version_control ->get_diff ( $ repo , $ newest_rev , $ oldest_rev , array ( 'ignore-space-change ' => true ) ) );
7068
7169 $ this ->stop_the_insanity ();
7270
@@ -80,7 +78,7 @@ public function run( $repo, $oldest_rev, $newest_rev ) {
8078 return $ error ;
8179 }
8280
83- $ diff_info = $ this ->diff_parser ->parse_diff_for_info ( $ diff );
81+ $ diff_info = $ this ->version_control ->parse_diff_for_info ( $ diff );
8482 $ file_diffs = $ diff_info ['file_diffs ' ];
8583
8684 $ found_issues = array ();
@@ -156,7 +154,7 @@ private function run_phpcs_for_file_revision( $filename, $revision ) {
156154
157155 if ( false === $ result ) {
158156
159- $ result = $ this ->diff_parser ->run_phpcs_for_file_at_revision ( $ filename , $ revision , $ this ->phpcs_command , $ this ->standards_location , $ this ->phpcs_standard );
157+ $ result = $ this ->version_control ->run_phpcs_for_file_at_revision ( $ filename , $ revision , $ this ->phpcs_command , $ this ->standards_location , $ this ->phpcs_standard );
160158
161159 if ( true !== $ this ->nocache ) {
162160 wp_cache_set ( $ cache_key , $ result , $ cache_group , 6 *HOUR_IN_SECONDS );
0 commit comments