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

EmailSubscriptionCriteria   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 5
dl 0
loc 32
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A findId() 0 8 2
A resolveId() 0 10 2
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