Pattern::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
namespace Openl10n\Cli\File;
4
5
class Pattern
6
{
7
    protected $pattern;
8
9
    public function __construct($pattern)
10
    {
11
        $this->pattern = $pattern;
12
    }
13
14
    public function toString(array $attributes = array())
15
    {
16
        $placeholders = array_map(function ($attribute) {
17
            return "<$attribute>";
18
        }, array_keys($attributes));
19
20
        return str_replace($placeholders, $attributes, $this->pattern);
21
    }
22
23
    public function __toString()
24
    {
25
        return $this->toString();
26
    }
27
}
28