for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Litipk\Jiffy;
/**
* Trait MongoAdapter: Only to be used inside UniversalTimestamp.
* @package Litipk\Jiffy
*/
trait MongoAdapter
{
* @param \MongoDate $mongoDate
* @return UniversalTimestamp
public static function fromMongoDate(\MongoDate $mongoDate)
return UniversalTimestamp::fromMillisecondsTimestamp(
$mongoDate->sec*1000 + (int)($mongoDate->usec/1000)
);
}
* @return \MongoDate
public function asMongoDate()
return new \MongoDate(
(int)floor($this->millis/1000),
millis
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;
1000*($this->millis%1000)
In PHP it is possible to write to properties without declaring them. For example, the following is perfectly valid PHP code:
Generally, it is a good practice to explictly declare properties to avoid accidental typos and provide IDE auto-completion: