DateTime::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
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