FormulaHelper   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 21
ccs 0
cts 14
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A processFormula() 0 17 2
1
<?php
2
namespace Mathielen\ReportWriteEngine\Utils;
3
4
class FormulaHelper
5
{
6
7
    public static function processFormula($cellValue, $rangeCellValue, $currentRowNum, $rangeRowNum)
8
    {
9
        if (substr($rangeCellValue, 0, 1) == '=') {
10
            $rowDelta = $currentRowNum + $rangeRowNum;
11
            //has ref to field - add row-offset
12
            $cellValue = preg_replace_callback(
13
                '/([A-Z]+)([0-9])+/',
14
                function ($matches) use ($rowDelta) {
15
                    $offsettedY = ($matches[2] + $rowDelta);
16
17
                    return $matches[1] . $offsettedY;
18
                },
19
                $cellValue);
20
        }
21
22
        return $cellValue;
23
    }
24
}
25