File   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 7
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 10
c 1
b 0
f 1
wmc 3

1 Method

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