Completed
Push — master ( e15c58...b150a8 )
by Changwan
07:08
created

StringReplacer::replace()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 3
dl 0
loc 4
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
namespace Wandu\Installation\Replacers;
3
4
use Wandu\Installation\Contracts\ReplacerInterface;
5
use SplFileInfo;
6
7
class StringReplacer implements ReplacerInterface
8
{
9
    /**
10
     * @param string $text
11
     */
12 1
    public function __construct($text)
13
    {
14 1
        $this->text = $text;
0 ignored issues
show
Bug introduced by
The property text does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
15 1
    }
16
17
    /**
18
     * {@inheritdoc}
19
     */
20 1
    public function replace($contents, $matcher, SplFileInfo $dest = null)
21
    {
22 1
        return preg_replace("/{$matcher}/", $this->text, $contents);
23
    }
24
}
25