1 | <?php |
||
29 | trait MongoHelper |
||
30 | { |
||
31 | /** |
||
32 | * Transforms a literal into a MongoDB ObjectId. |
||
33 | * |
||
34 | * @param $id - If it's an `ObjectID`, returns that, otherwise creates a new |
||
35 | * `ObjectID`. |
||
36 | * @return - The ObjectID |
||
|
|||
37 | */ |
||
38 | 1 | protected function toId($id): ObjectID |
|
42 | |||
43 | /** |
||
44 | * Transforms literals into MongoDB ObjectIds. |
||
45 | * |
||
46 | * @param iterable<mixed> $ids Goes through each entry, converts to `ObjectID` |
||
47 | * @return array<\MongoDB\BSON\ObjectID> The ObjectIDs |
||
48 | */ |
||
49 | protected function toIds(iterable $ids): array |
||
57 | |||
58 | /** |
||
59 | * Gets the current time. |
||
60 | * |
||
61 | * @return - The current time |
||
62 | * @deprecated 0.7.0:1.0.0 UTCDateTime now doesn't need an argument. |
||
63 | */ |
||
64 | protected function now(): \MongoDB\BSON\UTCDateTime |
||
69 | |||
70 | /** |
||
71 | * Tries to parse a date. |
||
72 | * |
||
73 | * @param $date - The possible string date value, a string, a |
||
74 | * `\DateTimeInterface`, or a `\MongoDB\BSON\UTCDateTime` |
||
75 | * @return - The MongoDB datetime or null |
||
76 | */ |
||
77 | protected function toDate($date): ?UTCDateTime |
||
88 | |||
89 | /** |
||
90 | * Makes sure a document isn't null. |
||
91 | * |
||
92 | * @param mixed $id The document identifier, either a `\MongoDB\BSON\ObjectID` or string |
||
93 | * @param mixed $document The document to check |
||
94 | * @return mixed Returns `$document` |
||
95 | * @throws \Caridea\Dao\Exception\Unretrievable if the document is null |
||
96 | */ |
||
97 | protected function ensure($id, $document) |
||
104 | } |
||
105 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.