Passed
Push — master ( 23ab98...82cce0 )
by y
01:46
created

Event::wasUndeletion()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Helix\Asana;
4
5
use Helix\Asana\Base\AbstractEntity;
6
use Helix\Asana\Base\Data;
7
use Helix\Asana\Event\Change;
8
use Helix\Asana\Project\Section;
9
use Helix\Asana\Task\Attachment;
10
use Helix\Asana\Task\Like;
11
use Helix\Asana\Task\Story;
12
13
/**
14
 * An event obtained via the API with a sync token.
15
 *
16
 * @see https://developers.asana.com/docs/get-events-on-a-resource
17
 * @see https://developers.asana.com/docs/event
18
 *
19
 * @method string                       getAction       ()
20
 * @method null|Change                  getChange       ()
21
 * @method bool                         hasChange       ()
22
 * @method string                       getCreatedAt    ()
23
 * @method null|Project|Section|Task    getParent       ()
24
 * @method bool                         hasParent       ()
25
 * @method AbstractEntity               getResource     ()
26
 * @method null|User                    getUser         ()
27
 * @method bool                         hasUser         ()
28
 */
29
class Event extends Data {
30
31
    const ACTION_CHANGED = 'changed';
32
    const ACTION_ADDED = 'added';
33
    const ACTION_REMOVED = 'removed';
34
    const ACTION_DELETED = 'deleted';
35
    const ACTION_UNDELETED = 'undeleted';
36
37
    const GRAPH = [
38
        User::TYPE => User::class,
39
        Project::TYPE => Project::class,
40
        Section::TYPE => Section::class,
41
        Task::TYPE => Task::class,
42
        Attachment::TYPE => Attachment::class,
43
        Story::TYPE => Story::class,
44
        Like::TYPE => Like::class
45
    ];
46
47
    protected const MAP = [
48
        'change' => Change::class,
49
        'parent' => '*',
50
        'parent*' => self::GRAPH,
51
        'resource' => '*',
52
        'resource*' => self::GRAPH,
53
        'user' => User::class
54
    ];
55
56
    final public function wasAddition (): bool {
57
        return $this->getAction() === self::ACTION_ADDED;
58
    }
59
60
    final public function wasChange (): bool {
61
        return $this->getAction() === self::ACTION_CHANGED;
62
    }
63
64
    final public function wasDeletion (): bool {
65
        return $this->getAction() === self::ACTION_DELETED;
66
    }
67
68
    final public function wasRemoval (): bool {
69
        return $this->getAction() === self::ACTION_REMOVED;
70
    }
71
72
    final public function wasUndeletion (): bool {
73
        return $this->getAction() === self::ACTION_UNDELETED;
74
    }
75
76
}