Exemple #1
0
function buildMongoOutput($data)
{
    return array_map(function ($x) {
        if ($x instanceof DateTimeImmutable) {
            $stamp = $x->getTimestamp();
            return new MongoDate($stamp);
        } elseif ($x instanceof FileInfo) {
            throw new Exception('Unexpected file!');
        } elseif (is_array($x)) {
            return buildMongoOutput($x);
        } else {
            return $x;
        }
    }, $data);
}
Exemple #2
0
 function run($data, $page)
 {
     $collection = $this->getClient();
     $collection->insert(buildMongoOutput($data));
     return $data;
 }