Completed
Push — new-version ( 103aac...769898 )
by Jeroen
02:41
created

DateTimeOrStringValue   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A __toString() 0 7 2
A getValue() 0 3 1
1
<?php
2
3
namespace JeroenDesloovere\VCard\Property\Value;
4
5
class DateTimeOrStringValue
6
{
7
    /**
8
     * @var string|\DateTime
9
     */
10
    protected $value;
11
12
    public function __construct($value)
13
    {
14
        $this->value = $value;
15
    }
16
17
    public function __toString(): string
18
    {
19
        if ($this->value instanceof \DateTime) {
20
            return $this->value->format('u');
21
        }
22
23
        return $this->value;
24
    }
25
26
    public function getValue()
27
    {
28
        return $this->value;
29
    }
30
}
31