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

VOString   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 71.43%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 27
ccs 5
cts 7
cp 0.7143
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A fromArrayMap() 0 4 1
1
<?php
2
3
namespace BestServedCold\PhalueObjects;
4
5
use BestServedCold\PhalueObjects\Exception\InvalidTypeException;
6
use BestServedCold\PhalueObjects\VOArray\Map;
7
8
/**
9
 * Class String
10
 *
11
 * @package   BestServedCold\PhalueObjects
12
 * @author    Adam Lewis <[email protected]>
13
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
14
 * @license      http://http://opensource.org/licenses/GPL-3.0 GPL License
15
 * @link      http://bestservedcold.com
16
 * @since      0.0.1-alpha
17
 * @version   0.0.2-alpha
18
 */
19
class VOString extends ValueObject
20
{
21
    /**
22
     * VOString constructor.
23
     *
24
     * @param  $value
25
     * @throws InvalidTypeException
26
     */
27 1
    public function __construct($value)
28
    {
29 1
        if (! is_string($value)) {
30 1
            throw new InvalidTypeException($value, ['string']);
31
        }
32
33 1
        parent::__construct($value);
34 1
    }
35
36
    /**
37
     * @param  Map    $map
38
     * @param  string $glue
39
     * @return string
40
     */
41
    public function fromArrayMap(Map $map, $glue = ',')
42
    {
43
        return implode($glue, $map->getValue());
44
    }
45
}
46