-
Notifications
You must be signed in to change notification settings - Fork 30
/
Monga.php
98 lines (88 loc) · 1.88 KB
/
Monga.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
<?php
/**
* Monga is a swift MongoDB Abstraction for PHP 5.3+
*
* @package Monga
* @version 1.0
* @author Frank de Jonge
* @license MIT License
* @copyright 2011 - 2012 Frank de Jonge
* @link http://github.com/php-leop/monga
*/
namespace League;
use League\Monga\Connection;
use MongoId;
use MongoCode;
use MongoDate;
use MongoDB;
use MongoRegex;
use MongoBinData;
class Monga
{
/**
* Returns a MongoBinData object
*
* @param string $data data
* @param int $type data type
* @return object MongoBinData
*/
public static function data($data, $type = null)
{
$type === null and $type = MongoBinData::BYTE_ARRAY;
return new MongoBinData($data, $type);
}
/**
* Create a MongoId object
*
* @param string $id id string
* @return object MongoId
*/
public static function id($id)
{
return new MongoId($id);
}
/**
* Create a MongoCode object
*
* @param string $code javascript string
* @param array $scope function scope
* @return object MongoCode
*/
public static function code($code, $scope = array())
{
return new MongoCode($code, $scope);
}
/**
* Create a MongoDate object
*
* @param int $sec timestamp
* @param int $usec
* @return object MongoDate
*/
public static function date($sec = null, $usec = 0)
{
$sec === null and $sec = time();
return new MongoDate($sec, $usec);
}
/**
* Create MongoRegex object
*
* @param string $regex regex
* @return object MongoRegex
*/
public static function regex($regex)
{
return new MongoRegex($regex);
}
/**
* Create a Monga\Connection object
*
* @param string $server server dns
* @param array $options connection options
* @return object Monga\Connection
*/
public static function connection($server = null, array $options = array())
{
return new Connection($server, $options);
}
}