CreatePayloadFromElementEvent   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 45
ccs 0
cts 22
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setPayload() 0 5 1
A getPayload() 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\ElementInterface;
12
use craft\helpers\StringHelper;
13
use yii\base\Event;
14
15
/**
16
 * @param ElementInterface $sender
17
 */
18
class CreatePayloadFromElementEvent extends Event
19
{
20
    /**
21
     * @var array
22
     */
23
    private $payload = [];
24
25
    /**
26
     * @param array $payload
27
     * @return $this
28
     */
29
    public function setPayload(array $payload)
30
    {
31
        $this->payload = $payload;
32
        return $this;
33
    }
34
35
    /**
36
     * @return array
37
     */
38
    public function getPayload(): array
39
    {
40
        return $this->payload;
41
    }
42
43
    /**
44
     * @param string $object
45
     * @param string|null $action
46
     * @return string
47
     */
48
    public static function eventName(
49
        string $object,
50
        string $action = null
51
    ): string {
52
        $name = array_filter([
53
            'payload',
54
            $object,
55
            $action
56
        ]);
57
58
        return StringHelper::toLowerCase(
59
            StringHelper::toString($name, ':')
60
        );
61
    }
62
}
63