Completed
Push — master ( f27ef8...e8179e )
by Pavel
02:17
created

PHPConstantsOutputAdapter::process()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 8
c 0
b 0
f 0
ccs 0
cts 8
cp 0
rs 9.4285
cc 3
eloc 5
nc 2
nop 3
crap 12
1
<?php
2
3
namespace Paro\EnvironmentParameters\Adapter\Output;
4
5
6
class PHPConstantsOutputAdapter implements OutputAdapterInterface
7
{
8
    public static function getName()
9
    {
10
        return 'php-constants';
11
    }
12
13
    public function process($parameters, $fileName, $env)
14
    {
15
        $content = sprintf("<?php\n/** This file is auto-generated during the build process of '%s' environment at %s **/\n", $env, date(DATE_ATOM));
16
        foreach ($parameters as $key => $value) {
17
            $content .= sprintf("define('%s', '%s');\n", $key, is_array($value) ? serialize($value) : addslashes($value));
18
        };
19
        file_put_contents($fileName, $content, 99);
20
    }
21
22
}