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

MongodbAdapter   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 19
ccs 4
cts 4
cp 1
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromMongodbUTCDateTime() 0 4 1
A asMongodbUTCDateTime() 0 4 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