ArrayDepth::toDepth()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 11
c 0
b 0
f 0
ccs 0
cts 9
cp 0
rs 9.4285
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
3
namespace BestServedCold\PhalueObjects\VOClosure;
4
5
use BestServedCold\PhalueObjects\VOClosure;
6
7
/**
8
 * Class Depth
9
 *
10
 * @package BestServedCold\PhalueObjects\VOClosure
11
 */
12
class ArrayDepth extends VOClosure
13
{
14
    public static function toDepth()
15
    {
16
        return new static(
17
            function (&$max) {
18
                return function ($line) use (&$max) {
19
                    // every line-indent equals 4 spaces
20
                    $max = max([$max, (strlen($line) - strlen(ltrim($line))) / 4]);
21
                };
22
            }
23
        );
24
    }
25
}
26