Passed
Push — master ( 1a00b5...984447 )
by y
03:02
created

Team::_getMap()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php
2
3
namespace Helix\Asana;
4
5
use Helix\Asana\Base\AbstractEntity;
6
7
/**
8
 * A team.
9
 *
10
 * @see https://developers.asana.com/docs/asana-teams
11
 * @see https://developers.asana.com/docs/team
12
 *
13
 * @immutable Teams cannot be altered via the API.
14
 *
15
 * @method string       getDescription      ()
16
 * @method string       getHtmlDescription  ()
17
 * @method string       getName             ()
18
 * @method Workspace    getOrganization     ()
19
 */
20
class Team extends AbstractEntity {
21
22
    const TYPE = 'team';
23
24
    protected static $map = [
25
        'organization' => Workspace::class
26
    ];
27
28
    final public function __toString (): string {
29
        return "teams/{$this->getGid()}";
30
    }
31
32
    /**
33
     * @param User $user
34
     * @return $this
35
     */
36
    public function addUser (User $user) {
37
        $this->api->post("{$this}/addUser", ['user' => $user->getGid()]);
38
        return $this;
39
    }
40
41
    public function getUrl (): string {
42
        return "https://app.asana.com/0/{$this->getGid()}/overview";
43
    }
44
45
    /**
46
     * @return User[]
47
     */
48
    public function getUsers () {
49
        return $this->loadAll(User::class, "{$this}/users");
50
    }
51
52
    /**
53
     * @param User $user
54
     * @return $this
55
     */
56
    public function removeUser (User $user) {
57
        $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]);
58
        return $this;
59
    }
60
}