| Conditions | 3 |
| Paths | 4 |
| Total Lines | 19 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 12 |
| CRAP Score | 3 |
| Changes | 0 | ||
| 1 | <?php |
||
| 45 | 2 | public function setValue($path, $value, $context = ConfigurationRepository::CONTEXT_DEFAULT) |
|
| 46 | { |
||
| 47 | 2 | $document = $this->mongo->findOne([ |
|
| 48 | 2 | 'context' => $context |
|
| 49 | ]); |
||
| 50 | 2 | $paths = explode('/', $path); |
|
| 51 | 2 | if ($document === null) { |
|
| 52 | $document = [ |
||
| 53 | 1 | 'context' => $context, |
|
| 54 | 'document'=> [] |
||
| 55 | ]; |
||
| 56 | } |
||
| 57 | 2 | $document['document'][$paths[0]][$paths[1]][$paths[2]] = $value; |
|
| 58 | 2 | if (isset($document['_id'])) { |
|
| 59 | 1 | $this->mongo->replaceOne(['_id' => $document['_id']], $document); |
|
| 60 | 1 | return; |
|
| 61 | } |
||
| 62 | 1 | $this->mongo->insertOne($document); |
|
| 63 | 1 | } |
|
| 64 | |||
| 72 |