1 | <?php |
||
21 | class MongoDBException extends \Exception |
||
22 | { |
||
23 | /** |
||
24 | * @return MongoDBException |
||
25 | */ |
||
26 | public static function detachedDocumentCannotBeRemoved() |
||
30 | |||
31 | /** |
||
32 | * @param string $state |
||
33 | * @return MongoDBException |
||
34 | */ |
||
35 | public static function invalidDocumentState($state) |
||
39 | |||
40 | /** |
||
41 | * @param string $className |
||
42 | * @return MongoDBException |
||
43 | */ |
||
44 | public static function documentNotMappedToCollection($className) |
||
48 | |||
49 | /** |
||
50 | * @return MongoDBException |
||
51 | */ |
||
52 | 5 | public static function documentManagerClosed() |
|
56 | |||
57 | /** |
||
58 | * @param string $documentNamespaceAlias |
||
59 | * @return MongoDBException |
||
60 | */ |
||
61 | public static function unknownDocumentNamespace($documentNamespaceAlias) |
||
62 | { |
||
63 | return new self(sprintf("Unknown Document namespace alias '%s'.", $documentNamespaceAlias)); |
||
64 | } |
||
65 | |||
66 | /** |
||
67 | * @param string $className |
||
68 | * @return MongoDBException |
||
69 | */ |
||
70 | 1 | public static function cannotPersistMappedSuperclass($className) |
|
71 | { |
||
72 | 1 | return new self('Cannot persist an embedded document, aggregation result document or mapped superclass ' . $className); |
|
73 | } |
||
74 | |||
75 | /** |
||
76 | * @param string $className |
||
77 | * @return MongoDBException |
||
78 | */ |
||
79 | public static function invalidDocumentRepository($className) |
||
80 | { |
||
81 | return new self(sprintf("Invalid repository class '%s'. It must be a %s.", $className, ObjectRepository::class)); |
||
82 | } |
||
83 | |||
84 | /** |
||
85 | * @param string $className |
||
86 | * @return MongoDBException |
||
87 | */ |
||
88 | public static function invalidGridFSRepository($className) |
||
89 | { |
||
90 | return new self(sprintf("Invalid repository class '%s'. It must be a %s.", $className, GridFSRepository::class)); |
||
91 | } |
||
92 | |||
93 | /** |
||
94 | * @param string $type |
||
95 | * @param string|array $expected |
||
96 | * @param mixed $got |
||
97 | * @return MongoDBException |
||
98 | */ |
||
99 | 4 | public static function invalidValueForType($type, $expected, $got) |
|
100 | { |
||
101 | 4 | if (is_array($expected)) { |
|
102 | 4 | $expected = sprintf( |
|
103 | 4 | '%s or %s', |
|
104 | 4 | implode(', ', array_slice($expected, 0, -1)), |
|
105 | 4 | end($expected) |
|
106 | ); |
||
107 | } |
||
108 | 4 | if (is_object($got)) { |
|
109 | 2 | $gotType = get_class($got); |
|
110 | 2 | } elseif (is_array($got)) { |
|
111 | $gotType = 'array'; |
||
112 | } else { |
||
113 | 2 | $gotType = 'scalar'; |
|
114 | } |
||
115 | 4 | return new self(sprintf('%s type requires value of type %s, %s given', $type, $expected, $gotType)); |
|
116 | } |
||
117 | |||
118 | /** |
||
119 | * @param string $field |
||
120 | * @param string $className |
||
121 | * @return MongoDBException |
||
122 | */ |
||
123 | public static function shardKeyFieldCannotBeChanged($field, $className) |
||
127 | |||
128 | /** |
||
129 | * @param string $field |
||
130 | * @param string $className |
||
131 | * @return MongoDBException |
||
132 | */ |
||
133 | public static function shardKeyFieldMissing($field, $className) |
||
137 | |||
138 | /** |
||
139 | * @param string $dbName |
||
140 | * @param string $errorMessage |
||
141 | * @return MongoDBException |
||
142 | */ |
||
143 | public static function failedToEnableSharding($dbName, $errorMessage) |
||
151 | |||
152 | /** |
||
153 | * @param string $className |
||
154 | * @param string $errorMessage |
||
155 | * @return MongoDBException |
||
156 | */ |
||
157 | public static function failedToEnsureDocumentSharding($className, $errorMessage) |
||
165 | |||
166 | /** |
||
167 | * @return MongoDBException |
||
168 | */ |
||
169 | public static function commitInProgress() |
||
173 | |||
174 | public static function documentBucketOnlyAvailableForGridFSFiles(string $className): self |
||
178 | |||
179 | 1 | public static function cannotPersistGridFSFile(string $className): self |
|
183 | |||
184 | public static function cannotReadGridFSSourceFile(string $filename): self |
||
188 | } |
||
189 |