Passed
Push — master ( 45a3bb...2cf7c0 )
by Thomas
03:37
created

Test_EncryptedModel   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
eloc 19
c 1
b 0
f 0
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getField() 0 3 1
A setField() 0 3 1
1
<?php
2
3
namespace LeKoala\Encrypt\Test;
4
5
use SilverStripe\Assets\File;
6
use SilverStripe\Dev\TestOnly;
7
use SilverStripe\ORM\DataObject;
8
use LeKoala\Encrypt\EncryptedDBText;
9
use LeKoala\Encrypt\EncryptedDBField;
10
use LeKoala\Encrypt\EncryptedDBVarchar;
11
use LeKoala\Encrypt\HasEncryptedFields;
12
use LeKoala\Encrypt\EncryptedDBHTMLText;
13
use LeKoala\Encrypt\EncryptedNumberField;
14
15
/**
16
 * A test model for our encryption
17
 *
18
 * @property string $Name
19
 * @property string $MyText
20
 * @property string $MyHTMLText
21
 * @property string $MyVarchar
22
 * @property string $MyNumber
23
 * @property string $MyVarcharWithIndex
24
 * @property int $RegularFileID
25
 * @property int $EncryptedFileID
26
 */
27
class Test_EncryptedModel extends DataObject implements TestOnly
28
{
29
    use HasEncryptedFields;
30
31
    private static $table_name = 'EncryptedModel';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
32
33
    private static $db = [
0 ignored issues
show
introduced by
The private property $db is not used, and could be removed.
Loading history...
34
        "Name" => 'Varchar',
35
        "MyText" => EncryptedDBText::class,
36
        "MyHTMLText" => EncryptedDBHTMLText::class,
37
        "MyVarchar" => EncryptedDBVarchar::class,
38
        "MyNumber" => EncryptedNumberField::class,
39
        "MyIndexedVarchar" => EncryptedDBField::class,
40
    ];
41
42
    private static $has_one = [
0 ignored issues
show
introduced by
The private property $has_one is not used, and could be removed.
Loading history...
43
        "RegularFile" => File::class,
44
        "EncryptedFile" => File::class,
45
    ];
46
47
    private static $indexes = [
0 ignored issues
show
introduced by
The private property $indexes is not used, and could be removed.
Loading history...
48
        'MyIndexedVarcharBlindIndex' => true,
49
        'MyNumberBlindIndex' => true,
50
        'MyNumberLastFourBlindIndex' => true,
51
    ];
52
53
    public function getField($field)
54
    {
55
        return $this->getEncryptedField($field);
56
    }
57
58
    public function setField($fieldName, $val)
59
    {
60
        return $this->setEncryptedField($fieldName, $val);
61
    }
62
}
63