Passed
Push — master ( f881c5...014efc )
by Leo
02:57
created

StateMethods   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 5
dl 0
loc 63
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A away() 0 3 1
A offline() 0 3 1
A online() 0 3 1
A getMandatoryFields() 0 3 1
A busy() 0 3 1
1
<?php
2
3
namespace leocata\M1\Methods;
4
5
use leocata\M1\Abstracts\Methods;
6
7
abstract class StateMethods extends Methods
8
{
9
10
    const OFFLINE = 0;
11
    const ONLINE = 1;
12
    const AWAY = 2;
13
    const BUSY = 3;
14
15
    /**
16
     * State:
17
     * 0 "offline" offline
18
     * 1 "online" online
19
     * 2 "away" absent (can receive calls, but shan't receive messages)
20
     * 3 "busy" busy (can receive messages, but shan’t receive calls)
21
     * @var integer
22
     */
23
    public $state;
24
25
    /**
26
     * User message.
27
     * @var string
28
     */
29
    public $note;
30
31
    /**
32
     * Set state online
33
     */
34
    public function online()
35
    {
36
        $this->state = self::ONLINE;
37
    }
38
39
    /**
40
     * Set state offline
41
     */
42
    public function offline()
43
    {
44
        $this->state = self::OFFLINE;
45
    }
46
47
    /**
48
     * Set state away
49
     */
50
    public function away()
51
    {
52
        $this->state = self::AWAY;
53
    }
54
55
    /**
56
     * Set state busy
57
     */
58
    public function busy()
59
    {
60
        $this->state = self::BUSY;
61
    }
62
63
    /**
64
     * Set Mandatory Fields for all methods
65
     * @return array
66
     */
67
    public function getMandatoryFields(): array
68
    {
69
        return ['state'];
70
    }
71
}
72