1 | <?php |
||
27 | class MongoDBException extends \Exception |
||
28 | { |
||
29 | /** |
||
30 | * @param string $documentName |
||
31 | * @param string $fieldName |
||
32 | * @param string $method |
||
33 | * @return MongoDBException |
||
34 | */ |
||
35 | public static function invalidFindByCall($documentName, $fieldName, $method) |
||
39 | |||
40 | /** |
||
41 | * @return MongoDBException |
||
42 | */ |
||
43 | public static function detachedDocumentCannotBeRemoved() |
||
47 | |||
48 | /** |
||
49 | * @param string $state |
||
50 | * @return MongoDBException |
||
51 | */ |
||
52 | public static function invalidDocumentState($state) |
||
56 | |||
57 | /** |
||
58 | * @param string $className |
||
59 | * @return MongoDBException |
||
60 | */ |
||
61 | public static function documentNotMappedToCollection($className) |
||
65 | |||
66 | /** |
||
67 | * @return MongoDBException |
||
68 | */ |
||
69 | 5 | public static function documentManagerClosed() |
|
73 | |||
74 | /** |
||
75 | * @param string $methodName |
||
76 | * @return MongoDBException |
||
77 | */ |
||
78 | public static function findByRequiresParameter($methodName) |
||
82 | |||
83 | /** |
||
84 | * @param string $documentNamespaceAlias |
||
85 | * @return MongoDBException |
||
86 | */ |
||
87 | public static function unknownDocumentNamespace($documentNamespaceAlias) |
||
91 | |||
92 | /** |
||
93 | * @param string $className |
||
94 | * @return MongoDBException |
||
95 | */ |
||
96 | 1 | public static function cannotPersistMappedSuperclass($className) |
|
100 | |||
101 | /** |
||
102 | * @param string $className |
||
103 | * @param string $unindexedFields |
||
104 | * @return MongoDBException |
||
105 | */ |
||
106 | 5 | public static function queryNotIndexed($className, $unindexedFields) |
|
107 | { |
||
108 | 5 | return new self(sprintf('Cannot execute unindexed queries on %s. Unindexed fields: %s', |
|
109 | $className, |
||
110 | 5 | implode(', ', $unindexedFields) |
|
111 | )); |
||
112 | } |
||
113 | |||
114 | /** |
||
115 | * @param string $className |
||
116 | * @return MongoDBException |
||
117 | */ |
||
118 | public static function invalidDocumentRepository($className) |
||
122 | |||
123 | /** |
||
124 | * @param string $type |
||
125 | * @param string|array $expected |
||
126 | * @param mixed $got |
||
127 | * @return MongoDBException |
||
128 | */ |
||
129 | 4 | public static function invalidValueForType($type, $expected, $got) |
|
130 | { |
||
131 | 4 | if (is_array($expected)) { |
|
132 | 4 | $expected = sprintf('%s or %s', |
|
133 | 4 | join(', ', array_slice($expected, 0, -1)), |
|
134 | end($expected) |
||
135 | ); |
||
136 | } |
||
137 | 4 | if (is_object($got)) { |
|
138 | 2 | $gotType = get_class($got); |
|
139 | 2 | } elseif (is_array($got)) { |
|
140 | $gotType = 'array'; |
||
141 | } else { |
||
142 | 2 | $gotType = 'scalar'; |
|
143 | } |
||
144 | 4 | return new self(sprintf('%s type requires value of type %s, %s given', $type, $expected, $gotType)); |
|
145 | } |
||
146 | |||
147 | /** |
||
148 | * @param string $field |
||
149 | * @param string $className |
||
150 | * @return MongoDBException |
||
151 | */ |
||
152 | public static function shardKeyFieldCannotBeChanged($field, $className) |
||
153 | { |
||
154 | return new self(sprintf('Shard key field "%s" cannot be changed. Class: %s', $field, $className)); |
||
155 | } |
||
156 | |||
157 | /** |
||
158 | * @param string $field |
||
159 | * @param string $className |
||
160 | * @return MongoDBException |
||
161 | */ |
||
162 | public static function shardKeyFieldMissing($field, $className) |
||
166 | |||
167 | /** |
||
168 | * @param string $dbName |
||
169 | * @param string $errorMessage |
||
170 | * @return MongoDBException |
||
171 | */ |
||
172 | public static function failedToEnableSharding($dbName, $errorMessage) |
||
179 | |||
180 | /** |
||
181 | * @param string $className |
||
182 | * @param string $errorMessage |
||
183 | * @return MongoDBException |
||
184 | */ |
||
185 | public static function failedToEnsureDocumentSharding($className, $errorMessage) |
||
192 | } |
||
193 |