Passed
Pull Request — 1.11.x (#4160)
by Angel Fernando Quiroz
07:54
created

RegistrantSchema   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 95
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
eloc 32
c 1
b 0
f 0
dl 0
loc 95
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A itemClass() 0 6 2
A fromEmailAndFirstName() 0 10 2
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\Zoom\API;
6
7
abstract class RegistrantSchema
8
{
9
    use JsonDeserializableTrait;
10
11
    /** @var string */
12
    public $email;
13
14
    /**
15
     * @var string
16
     */
17
    public $status;
18
19
    /** @var string */
20
    public $first_name;
21
22
    /** @var string */
23
    public $last_name;
24
25
    /** @var string */
26
    public $address;
27
28
    /** @var string */
29
    public $city;
30
31
    /** @var string */
32
    public $country;
33
34
    /** @var string */
35
    public $zip;
36
37
    /** @var string */
38
    public $state;
39
40
    /** @var string */
41
    public $phone;
42
43
    /** @var string */
44
    public $industry;
45
46
    /** @var string */
47
    public $org;
48
49
    /** @var string */
50
    public $job_title;
51
52
    /** @var string */
53
    public $purchasing_time_frame;
54
55
    /** @var string */
56
    public $role_in_purchase_process;
57
58
    /** @var string */
59
    public $no_of_employees;
60
61
    /** @var string */
62
    public $comments;
63
64
    /** @var object[] title => value */
65
    public $custom_questions;
66
67
    /**
68
     * @var string
69
     */
70
    public $language;
71
72
    /**
73
     * MeetingRegistrant constructor.
74
     */
75
    public function __construct()
76
    {
77
        $this->status = 'approved';
78
        $this->custom_questions = [];
79
    }
80
81
    public static function fromEmailAndFirstName(string $email, string $firstName, string $lastName = null): RegistrantSchema
82
    {
83
        $instance = new static();
84
        $instance->first_name = $firstName;
85
        $instance->email = $email;
86
        if (null !== $lastName) {
87
            $instance->last_name = $lastName;
88
        }
89
90
        return $instance;
91
    }
92
93
    /**
94
     * {@inheritdoc}
95
     */
96
    public function itemClass($propertyName): string
97
    {
98
        if ('custom_questions' === $propertyName) {
99
            return CustomQuestion::class;
100
        }
101
        throw new Exception("no such array property $propertyName");
0 ignored issues
show
Bug introduced by
The type Chamilo\PluginBundle\Zoom\API\Exception was not found. Did you mean Exception? If so, make sure to prefix the type with \.
Loading history...
102
    }
103
}
104