Completed
Push — master ( 58c1c3...bed08d )
by Andreu
04:34
created

MongodbAdapter::asMongodbUTCDateTime()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 1
1
<?php
2
3
4
namespace Litipk\Jiffy;
5
6
7
/**
8
 * Trait MongodbAdapter: Only to be used inside UniversalTimestamp.
9
 * @package Litipk\Jiffy
10
 */
11
trait MongodbAdapter
12
{
13
    /**
14
     * @param \MongoDB\BSON\UTCDatetime $mongoDate
15
     * @return UniversalTimestamp
16
     */
17 2
    public static function fromMongodbUTCDateTime(\MongoDB\BSON\UTCDatetime $mongoDate)
18
    {
19 2
        return UniversalTimestamp::fromMillisecondsTimestamp((int)$mongoDate->__toString());
20
    }
21
22
    /**
23
     * @return \MongoDate
24
     */
25 1
    public function asMongodbUTCDateTime()
26
    {
27 1
        return new \MongoDB\BSON\UTCDatetime($this->millis);
0 ignored issues
show
Bug introduced by
The property millis does not exist. Did you maybe forget to declare it?

In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:

class MyClass { }

$x = new MyClass();
$x->foo = true;

Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion:

class MyClass {
    public $foo;
}

$x = new MyClass();
$x->foo = true;
Loading history...
28
    }
29
}
30