Passed
Push — codex/add-windows-support ( 159586...f97206 )
by Chema
08:06 queued 02:47
created

setup_git_hooks()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 16
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
dl 0
loc 16
rs 10
c 1
b 0
f 0
cc 3
nc 4
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
function setup_git_hooks(): void
6
{
7
    echo "Initialising git hooks..." . PHP_EOL;
8
9
    $preCommitSource = __DIR__ . DIRECTORY_SEPARATOR . 'pre-commit.sh';
10
    $preCommitTarget = dirname(__DIR__, 2) . DIRECTORY_SEPARATOR . '.git' . DIRECTORY_SEPARATOR . 'hooks' . DIRECTORY_SEPARATOR . 'pre-commit';
11
12
    if (file_exists($preCommitTarget)) {
13
        unlink($preCommitTarget);
14
    }
15
16
    if (!@symlink($preCommitSource, $preCommitTarget)) {
17
        copy($preCommitSource, $preCommitTarget);
18
    }
19
20
    echo "Done" . PHP_EOL;
21
}
22
23
setup_git_hooks();
24
25