Passed
Push — master ( f38812...1d8a89 )
by Mike
03:19
created

MixpanelEvent::name()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 0
dl 0
loc 9
rs 9.6666
c 0
b 0
f 0
1
<?php namespace GeneaLabs\LaravelMixpanel\Events;
2
3
use Illuminate\Queue\SerializesModels;
4
5
class MixpanelEvent
6
{
7
    use SerializesModels;
0 ignored issues
show
introduced by
The trait Illuminate\Queue\SerializesModels requires some properties which are not provided by GeneaLabs\LaravelMixpanel\Events\MixpanelEvent: $id, $class, $connection, $relations
Loading history...
8
9
    public $charge;
10
    public $profileData;
11
    public $trackingData;
12
    public $user;
13
14
    public function __construct($user, array $trackingData, int $charge = 0, array $profileData = [])
15
    {
16
        $this->charge = $charge;
17
        $this->trackingData = $trackingData;
18
        $this->profileData = $profileData;
19
        $this->user = $user;
20
    }
21
22
    public function name() : string
23
    {
24
        $name = array_keys($this->trackingData)[0];
25
26
        if ($name === 0) {
27
            $name = $this->trackingData[0];
28
        }
29
30
        return $name;
31
    }
32
}
33