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

File   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
c 0
b 0
f 0
lcom 0
cbo 1
dl 0
loc 14
ccs 0
cts 11
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A write() 0 11 3
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