| Conditions | 4 |
| Paths | 2 |
| Total Lines | 28 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 19 | public function safeUp() |
||
| 20 | { |
||
| 21 | $widgetResults = (new Query()) |
||
| 22 | ->select('*') |
||
| 23 | ->from(['{{%widgets}}']) |
||
| 24 | ->where(['type' => 'dukt\analytics\widgets\Realtime']) |
||
| 25 | ->orWhere(['type' => 'dukt\analytics\widgets\Report']) |
||
| 26 | ->all(); |
||
| 27 | |||
| 28 | if ($widgetResults) { |
||
|
|
|||
| 29 | foreach ($widgetResults as $result) { |
||
| 30 | $settings = Json::decode($result['settings']); |
||
| 31 | |||
| 32 | if (isset($settings['options']['metric'])) { |
||
| 33 | $settings['options'] = [ |
||
| 34 | $settings['chart'] => $settings['options'] |
||
| 35 | ]; |
||
| 36 | } |
||
| 37 | |||
| 38 | // Update row |
||
| 39 | |||
| 40 | $settings = Json::encode($settings); |
||
| 41 | |||
| 42 | $this->update('{{%widgets}}', ['settings' => $settings], ['id' => $result['id']]); |
||
| 43 | } |
||
| 44 | } |
||
| 45 | |||
| 46 | return true; |
||
| 47 | } |
||
| 59 |
This check marks implicit conversions of arrays to boolean values in a comparison. While in PHP an empty array is considered to be equal (but not identical) to false, this is not always apparent.
Consider making the comparison explicit by using
empty(..)or! empty(...)instead.