PrintFileTrait::getPrintableFile()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 5
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration;
5
6
trait PrintFileTrait
7
{
8
    public function getPrintableFile(string $contents): string
9
    {
10
        $lines = explode(PHP_EOL, $contents);
11
        $i = 1;
12
        return implode(PHP_EOL, array_map(function ($line) use (&$i) {
13
            return $i++ . ':' . $line;
14
        }, $lines));
15
    }
16
}
17