DateTime   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 34
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 3
A __toString() 0 3 1
1
<?php
2
/**
3
 * @category    Brownie/BpmOnline
4
 * @author      Brownie <[email protected]>
5
 * @license     https://opensource.org/licenses/MIT
6
 */
7
8
namespace Brownie\BpmOnline\Util;
9
10
/**
11
 * The class DateTime for the formation of time in the requests.
12
  */
13
class DateTime
14
{
15
16
    /**
17
     * Timestamp in queries.
18
     *
19
     * @var int  $dateTime
20
     */
21
    private $dateTime;
22
23
    /**
24
     * Sets the input values.
25
     *
26
     * @param mixed   $dateTime   Time in queries.
27
     */
28 3
    public function __construct($dateTime = null)
29
    {
30 3
        if (empty($dateTime)) {
31 1
            $dateTime = time();
32
        }
33 3
        $this->dateTime = $dateTime;
34 3
        if (!is_numeric($dateTime)) {
35 1
            $this->dateTime = strtotime($dateTime);
36
        }
37 3
    }
38
39
    /**
40
     * Returns the time as a string to pass to bpm'online.
41
     *
42
     * @return string
43
     */
44 3
    public function __toString()
45
    {
46 3
        return '"' . date('c', $this->dateTime) . '"';
47
    }
48
}
49