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