Completed
Push — master ( a4e176...8c9478 )
by Adam
02:50
created

Attribute   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 100%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromArray() 0 5 1
A fromArrayString() 0 6 2
1
<?php
2
3
namespace BestServedCold\PhalueObjects\Format;
4
5
use BestServedCold\PhalueObjects\Format;
6
use BestServedCold\PhalueObjects\VOArray\Map;
7
8
/**
9
 * Class Attribute
10
 *
11
 * @package BestServedCold\PhalueObjects\Format
12
 */
13
class Attribute extends Format
14
{
15
    /**
16
     * @param array $array
17
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be Attribute?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
18
     */
19 1
    public static function fromArray(array $array)
20
    {
21 1
        $map = new Map(self::fromArrayString(), array_keys($array), $array);
22 1
        return new static(implode(' ', $map->getValue()));
23
    }
24
25
    /**
26
     * return \Closure
27
     */
28
    private static function fromArrayString()
29
    {
30 1
        return function ($key, $value) {
31 1
            return is_null($value) ? $key : $key.'="'.$value.'"';
32 1
        };
33
    }
34
}
35