Passed
Push — main ( a0e9c5...805967 )
by Paul
07:42
created

Migrate_6_11_0   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 78.56%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 4
eloc 13
dl 0
loc 28
ccs 11
cts 14
cp 0.7856
rs 10
c 1
b 0
f 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A migrateReviewNotifications() 0 14 3
A run() 0 4 1
1
<?php
2
3
namespace GeminiLabs\SiteReviews\Migrations;
4
5
use GeminiLabs\SiteReviews\Contracts\MigrateContract;
6
7
class Migrate_6_11_0 implements MigrateContract
8
{
9
    /**
10
     * Run migration.
11
     */
12 23
    public function run(): bool
13
    {
14 23
        $this->migrateReviewNotifications();
15 23
        return true;
16
    }
17
18
    /**
19
     * Rename WooCommerce Notification settings key (Review Notifications).
20
     */
21 23
    public function migrateReviewNotifications(): void
22
    {
23 23
        $oldKey = 'woocommerce_glsr_reminder_settings';
24 23
        $newKey = 'woocommerce_glsr_customer_review_reminder_settings';
25 23
        $old = get_option($oldKey);
26 23
        $new = get_option($newKey);
27 23
        if (!empty($new)) {
28
            return;
29
        }
30 23
        if (empty($old)) {
31 23
            return;
32
        }
33
        update_option($newKey, $old);
34
        delete_option($oldKey);
35
    }
36
}
37