Passed
Push — master ( 2428ce...06a092 )
by y
02:04
created

Status::_getDir()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Helix\Asana\Project;
4
5
use Helix\Asana\Base\AbstractEntity;
6
use Helix\Asana\Base\AbstractEntity\CreateTrait;
7
use Helix\Asana\Base\AbstractEntity\DeleteTrait;
8
use Helix\Asana\Base\AbstractEntity\ImmutableInterface;
9
use Helix\Asana\Project;
10
use Helix\Asana\User;
11
12
/**
13
 * A project status.
14
 *
15
 * @see https://developers.asana.com/docs/asana-project-statuses
16
 * @see https://developers.asana.com/docs/project-status
17
 *
18
 * @immutable Statuses may only be deleted after creation.
19
 *
20
 * @method string   getColor        () @depends after-create
21
 * @method string   getCreatedAt    () RFC3339x
22
 * @method User     getCreatedBy    ()
23
 * @method string   getText         ()
24
 * @method string   getTitle        ()
25
 *
26
 * @method $this    setColor        (string $color) @depends create-only, `green|red|yellow`
27
 * @method $this    setText         (string $text)  @depends create-only
28
 */
29
class Status extends AbstractEntity implements ImmutableInterface {
30
31
    use CreateTrait;
32
    use DeleteTrait;
33
34
    const DIR = 'project_statuses';
35
    const TYPE = 'project_status';
36
37
    const COLOR_GREEN = 'green';
38
    const COLOR_RED = 'red';
39
    const COLOR_YELLOW = 'yellow';
40
41
    protected const MAP = [
42
        'created_by' => User::class
43
    ];
44
45
    /**
46
     * @var Project
47
     */
48
    protected $parent;
49
50
    /**
51
     * @param Project $project
52
     * @param array $data
53
     */
54
    public function __construct (Project $project, array $data = []) {
55
        $this->parent = $project;
56
        parent::__construct($project, $data);
57
    }
58
59
    protected function _setData (array $data): void {
60
        // redundant, prefer created_by
61
        unset($data['author']);
62
63
        parent::_setData($data);
64
    }
65
66
    /**
67
     * @return Project
68
     */
69
    public function getProject () {
70
        return $this->parent;
71
    }
72
}