Passed
Push — master ( c22b6a...5f79f5 )
by Julito
11:21
created

Meeting   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 21
c 0
b 0
f 0
dl 0
loc 69
rs 10
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A create() 0 3 1
A itemClass() 0 6 2
A fromTopicAndType() 0 7 1
1
<?php
2
3
/* For licensing terms, see /license.txt */
4
5
namespace Chamilo\PluginBundle\Zoom\API;
6
7
use Exception;
8
9
/**
10
 * Class Meeting, minimal meeting definition required to create one from scratch or update an existing one
11
 * Also referred to as MeetingUpdate in the API documentation
12
 * Does not represent an actual created meeting.
13
 */
14
class Meeting
15
{
16
    use BaseMeetingTrait;
17
    use JsonDeserializableTrait;
18
19
    const TYPE_INSTANT = 1;
20
    const TYPE_SCHEDULED = 2;
21
    const TYPE_RECURRING_WITH_NO_FIXED_TIME = 3;
22
    const TYPE_RECURRING_WITH_FIXED_TIME = 8;
23
24
    /** @var string password to join. [a-z A-Z 0-9 @ - _ *]. Max of 10 characters. */
25
    public $password;
26
27
    /** @var TrackingField[] Tracking fields */
28
    public $tracking_fields;
29
30
    /** @var object, only for a recurring meeting with fixed time (type 8) */
31
    public $recurrence;
32
33
    /** @var MeetingSettings */
34
    public $settings;
35
36
    /**
37
     * Meeting constructor.
38
     */
39
    protected function __construct()
40
    {
41
        $this->tracking_fields = [];
42
        $this->settings = new MeetingSettings();
43
    }
44
45
    /**
46
     * {@inheritdoc}
47
     */
48
    public function itemClass($propertyName)
49
    {
50
        if ('tracking_fields' === $propertyName) {
51
            return TrackingField::class;
52
        }
53
        throw new Exception("no such array property $propertyName");
54
    }
55
56
    /**
57
     * Creates a meeting on the server and returns the resulting MeetingInfoGet.
58
     *
59
     * @throws Exception describing the error (message and code)
60
     *
61
     * @return MeetingInfoGet meeting
62
     */
63
    public function create()
64
    {
65
        return MeetingInfoGet::fromJson(Client::getInstance()->send('POST', 'users/me/meetings', [], $this));
66
    }
67
68
    /**
69
     * Creates a Meeting instance from a topic.
70
     *
71
     * @param string $topic
72
     * @param int    $type
73
     *
74
     * @return static
75
     */
76
    public static function fromTopicAndType($topic, $type = self::TYPE_SCHEDULED)
77
    {
78
        $instance = new static();
79
        $instance->topic = $topic;
80
        $instance->type = $type;
81
82
        return $instance;
83
    }
84
}
85