Completed
Push — master ( 883af0...e98a3d )
by Andrii
02:51
created

File::write()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 11
ccs 0
cts 11
cp 0
rs 9.4285
cc 3
eloc 7
nc 3
nop 2
crap 12
1
<?php
2
3
/*
4
 * Changelog keeper
5
 *
6
 * @link      https://github.com/hiqdev/chkipper
7
 * @package   chkipper
8
 * @license   BSD-3-Clause
9
 * @copyright Copyright (c) 2016, HiQDev (http://hiqdev.com/)
10
 */
11
12
namespace hiqdev\chkipper\helpers;
13
14
use yii\helpers\Console;
15
16
/**
17
 * File helper class.
18
 *
19
 * @author Andrii Vasyliev <[email protected]>
20
 */
21
class File
22
{
23
    public static function write($path, $content)
24
    {
25
        if (file_exists($path)) {
26
            $old = file_get_contents($path);
27
            if ($old === $content) {
28
                return;
29
            }
30
        }
31
        file_put_contents($path, $content);
32
        Console::stdout(Console::ansiFormat("written file: $path\n", [Console::FG_YELLOW]));
33
    }
34
}
35