ScriptHandler   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 0
dl 0
loc 21
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A addPhpCsToPreCommitHook() 0 16 3
1
<?php
2
3
/*
4
 * This file is part of Zenify
5
 * Copyright (c) 2012 Tomas Votruba (http://tomasvotruba.cz)
6
 */
7
8
namespace Zenify\CodingStandard\Composer;
9
10
11
final class ScriptHandler
12
{
13
14
	public static function addPhpCsToPreCommitHook()
15
	{
16
		$originFile = getcwd() . '/.git/hooks/pre-commit';
17
		$templateContent = file_get_contents(__DIR__ . '/templates/git/hooks/pre-commit-phpcs');
18
		if (file_exists($originFile)) {
19
			$originContent = file_get_contents($originFile);
20
			if (strpos($originContent, '# run phpcs') === FALSE) {
21
				$newContent = $originContent . PHP_EOL . PHP_EOL . $templateContent;
22
				file_put_contents($originFile, $newContent);
23
			}
24
25
		} else {
26
			file_put_contents($originFile, $templateContent);
27
		}
28
		chmod($originFile, 0755);
29
	}
30
31
}
32