Passed
Push — master ( a6b666...4a55f1 )
by Thomas
03:02
created

TestExcelMember::onBeforeWrite()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace LeKoala\ExcelImportExport\Test\Mocks;
4
5
use SilverStripe\Dev\TestOnly;
6
use SilverStripe\Security\Member;
7
use Exception;
8
9
class TestExcelMember extends Member implements TestOnly
10
{
11
    public function onBeforeWrite()
12
    {
13
        parent::onBeforeWrite();
14
15
        // For older ss versions that do not validate emails
16
        if ($this->Email && !filter_var($this->Email, FILTER_VALIDATE_EMAIL)) {
17
            throw new Exception("Email is not valid");
18
        }
19
    }
20
}
21