| Conditions | 3 |
| Paths | 3 |
| Total Lines | 25 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 0 |
| CRAP Score | 12 |
| Changes | 0 | ||
| 1 | <?php |
||
| 36 | public function start(): bool |
||
| 37 | { |
||
| 38 | $cursor = $this->db->storage->find([ |
||
| 39 | 'pointer' => ['$exists' => false], |
||
| 40 | ]); |
||
| 41 | |||
| 42 | foreach ($cursor as $object) { |
||
| 43 | if (isset($object['reference'])) { |
||
| 44 | $pointer = $object['reference']; |
||
| 45 | } else { |
||
| 46 | $pointer = $object['_id']; |
||
| 47 | } |
||
| 48 | |||
| 49 | $this->db->storage->updateOne( |
||
| 50 | ['_id' => $object['_id']], |
||
| 51 | [ |
||
| 52 | '$set' => ['pointer' => $pointer], |
||
| 53 | ] |
||
| 54 | ); |
||
| 55 | } |
||
| 56 | |||
| 57 | $this->db->selectCollection('storage')->createIndex(['pointer' => 1]); |
||
| 58 | |||
| 59 | return true; |
||
| 60 | } |
||
| 61 | } |
||
| 62 |