Completed
Push — master ( 04ac75...81967b )
by Nate
17:06
created

m181018_081114_encrypt   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 0
loc 27
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A safeUp() 0 13 2
A safeDown() 0 4 1
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/patron/license
6
 * @link       https://www.flipboxfactory.com/software/patron/
7
 */
8
9
namespace flipbox\patron\migrations;
10
11
use craft\db\Migration;
12
use flipbox\patron\Patron;
13
use flipbox\patron\records\Provider;
14
use flipbox\patron\records\ProviderInstance;
15
16
class m181018_081114_encrypt extends Migration
17
{
18
    /**
19
     * @inheritdoc
20
     */
21
    public function safeUp()
22
    {
23
        $this->alterColumn(
24
            Provider::tableName(),
25
            'clientSecret',
26
            $this->char(ProviderInstance::CLIENT_SECRET_LENGTH)
27
        );
28
29
        // Encrypt those that are not
30
        if (Patron::getInstance()->getSettings()->getEncryptStorageData() === true) {
31
            Patron::getInstance()->manageProviders()->changeEncryption(true);
32
        }
33
    }
34
35
    /**
36
     * @inheritdoc
37
     */
38
    public function safeDown()
39
    {
40
        return true;
41
    }
42
}
43