Completed
Push — master ( e104ff...0b0948 )
by Nate
02:40 queued 10s
created

EmailSubscriptionCriteria::resolveId()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
dl 0
loc 10
ccs 0
cts 8
cp 0
rs 9.9332
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 6
1
<?php
2
3
/**
4
 * @copyright  Copyright (c) Flipbox Digital Limited
5
 * @license    https://flipboxfactory.com/software/hubspot/license
6
 * @link       https://www.flipboxfactory.com/software/hubspot/
7
 */
8
9
namespace flipbox\craft\hubspot\criteria;
10
11
use craft\elements\User;
12
use flipbox\craft\ember\objects\ElementAttributeTrait;
13
14
/**
15
 * @author Flipbox Factory <[email protected]>
16
 * @since 1.2.0
17
 */
18
class EmailSubscriptionCriteria extends \Flipbox\HubSpot\Criteria\EmailSubscriptionCriteria
19
{
20
    use CacheTrait,
21
        ConnectionTrait,
22
        ElementAttributeTrait;
23
24
    /**
25
     * @return string|null
26
     */
27
    public function findId()
28
    {
29
        if (null === $this->id) {
30
            $this->id = $this->resolveId();
31
        }
32
33
        return $this->id;
34
    }
35
36
    /**
37
     * @return string|null
38
     */
39
    protected function resolveId()
40
    {
41
        $element = $this->getElement();
42
43
        if (!$element instanceof User) {
44
            return null;
45
        }
46
47
        return $element->email;
48
    }
49
}
50