Value   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArrayWithPlural() 0 13 3
1
<?php
2
3
namespace BestServedCold\PhalueObjects\VOClosure;
4
5
use BestServedCold\PhalueObjects\VOClosure;
6
use BestServedCold\PhalueObjects\VOString\Word;
7
8
/**
9
 * Class Value
10
 *
11
 * @package BestServedCold\PhalueObjects\VOClosure
12
 */
13
class Value extends VOClosure
14
{
15
    /**
16
     * @param  bool   $pluralValue
17
     * @param  bool   $pluralKey
18
     * @return static
19
     */
20 2
    public static function toArrayWithPlural($pluralValue = false, $pluralKey = false)
21
    {
22 2
        return new static(
23 2
            function ($value) use ($pluralValue, $pluralKey) {
24 2
                return array_filter([
25 2
                    key($value),
26 2
                    reset($value),
27 2
                    $pluralKey ? Word::fromString(key($value))->getPluralised() : null,
28 2
                    $pluralValue ? Word::fromString(reset($value))->getPluralised() : null
29 2
                ]);
30
            }
31 2
        );
32
    }
33
}
34