FileManipulations   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 1
dl 0
loc 15
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A strReplaceInFile() 0 8 2
A strReplaceInFileAnyway() 0 4 1
1
<?php namespace Savannabits\JetstreamInertiaGenerator\Generators\Traits;
2
3
use Illuminate\Support\Facades\File;
4
5
trait FileManipulations {
6
7
    protected function strReplaceInFile($fileName, $ifExistsRegex, $find, $replaceWith) {
8
        $content = File::get($fileName);
9
        if (preg_match($ifExistsRegex, $content)) {
10
            return null;
11
        }
12
13
        return File::put($fileName, str_replace($find, $replaceWith, $content));
14
    }
15
    protected function strReplaceInFileAnyway($fileName, $find, $replaceWith) {
16
        $content = File::get($fileName);
17
        return File::put($fileName, str_replace($find, $replaceWith, $content));
18
    }
19
}
20