Completed
Pull Request — master (#82)
by
unknown
16:22 queued 08:47
created

OperatorTools   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
B inlineMixedInstructions() 0 20 5
1
<?php
2
3
namespace RulerZ\Target\Operators;
4
5
class OperatorTools
6
{
7
    public static function inlineMixedInstructions(array $instructions, $operator = null)
8
    {
9
        $elements = [];
10
11
        foreach ($instructions as $instruction) {
12
            if ($instruction instanceof RuntimeOperator) {
13
                $elements[] = $instruction->format(false);
14
            } else if ($instruction instanceof CompileTimeOperator) {
15
                $elements[] = sprintf('%s', $instruction->format(false));
16
            } else {
17
                $elements[] = sprintf('%s', $instruction);
18
            }
19
        }
20
21
        if (null === $operator) {
22
            return join('', $elements);
23
        } else {
24
            return join(' '.$operator.' ', $elements);
25
        }
26
    }
27
}
28