Completed
Push — master ( f63d98...a1095d )
by Angus
05:43
created

setup.php ➔ chmod_files()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php
2
3
(PHP_SAPI !== 'cli' || isset($_SERVER['HTTP_USER_AGENT'])) && die('CLI only.');
4
5
chdir(realpath(dirname(__FILE__."../", 2))); //Navigate to root DIR
6
7
function setup() {
8
	vendor_copy();
9
10
	chmod_files();
11
12
	//Make sure .gitkeep file is recreated
13
	touch(getcwd()."/application/tests/_ci_phpunit_test/.gitkeep");
14
}
15
16
/**********************************************************************************************************************/
17
18
function vendor_copy() {
19
	$json = json_decode(file_get_contents('composer.json'), TRUE)['vendor-copy'];
20
	array_map('copy', array_keys($json), $json);
21
}
22
23
function chmod_files() {
24
	$directory = new RecursiveDirectoryIterator(getcwd()."/application/config");
25
	$flattened = new RecursiveIteratorIterator($directory);
26
27
	$files = new RegexIterator($flattened, '/^(.*\/)?(database|database_password|config|email|recaptcha|sites)\.php/');
28
	foreach($files as $file) {
29
		chmod($file, 0644);
30
	}
31
}
32