PopulateElementFromResponseEvent   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 68
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
lcom 0
cbo 2
dl 0
loc 68
ccs 0
cts 31
cp 0
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A setResponse() 0 5 1
A getResponse() 0 4 1
A setField() 0 5 1
A getField() 0 4 1
A eventName() 0 14 1
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\events;
10
11
use craft\base\Element;
12
use craft\base\ElementInterface;
13
use craft\helpers\StringHelper;
14
use flipbox\craft\hubspot\fields\ObjectsFieldInterface;
15
use Psr\Http\Message\ResponseInterface;
16
use yii\base\Event;
17
18
/**
19
 * @property ElementInterface|Element $sender
20
 */
21
class PopulateElementFromResponseEvent extends Event
22
{
23
    /**
24
     * @var ResponseInterface
25
     */
26
    private $response;
27
28
    /**
29
     * @var ObjectsFieldInterface
30
     */
31
    private $field;
32
33
    /**
34
     * @param ResponseInterface $response
35
     * @return $this
36
     */
37
    public function setResponse(ResponseInterface $response)
38
    {
39
        $this->response = $response;
40
        return $this;
41
    }
42
43
    /**
44
     * @return ResponseInterface
45
     */
46
    public function getResponse(): ResponseInterface
47
    {
48
        return $this->response;
49
    }
50
51
    /**
52
     * @param ObjectsFieldInterface $field
53
     * @return $this
54
     */
55
    public function setField(ObjectsFieldInterface $field)
56
    {
57
        $this->field = $field;
58
        return $this;
59
    }
60
61
    /**
62
     * @return ObjectsFieldInterface
63
     */
64
    public function getField(): ObjectsFieldInterface
65
    {
66
        return $this->field;
67
    }
68
69
    /**
70
     * @param string $object
71
     * @param string|null $action
72
     * @return string
73
     */
74
    public static function eventName(
75
        string $object,
76
        string $action = null
77
    ): string {
78
        $name = array_filter([
79
            'populate',
80
            $object,
81
            $action
82
        ]);
83
84
        return StringHelper::toLowerCase(
85
            StringHelper::toString($name, ':')
86
        );
87
    }
88
}
89