| Conditions | 2 |
| Paths | 2 |
| Total Lines | 16 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 9 |
| CRAP Score | 2.004 |
| Changes | 0 | ||
| 1 | <?php |
||
| 60 | 1 | public function setValue($key, $value) |
|
| 61 | { |
||
| 62 | 1 | $exists = (new Query()) |
|
| 63 | 1 | ->from($this->tableName) |
|
| 64 | 1 | ->where(['id' => $key]) |
|
| 65 | 1 | ->exists($this->db); |
|
| 66 | |||
| 67 | 1 | $query = (new Query())->createCommand($this->db); |
|
| 68 | |||
| 69 | 1 | if ($exists) { |
|
| 70 | $result = $query->update($this->tableName, ['data' => $value], ['id' => $key])->execute(); |
||
| 71 | } else { |
||
| 72 | 1 | $result = $query->insert($this->tableName, ['id' => $key, 'data' => $value])->execute(); |
|
| 73 | } |
||
| 74 | 1 | return $result > 0; |
|
| 75 | } |
||
| 76 | |||
| 90 |