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

Team::__toString()   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\AbstractEntity\ImmutableInterface;
7
8
/**
9
 * A team.
10
 *
11
 * @see https://developers.asana.com/docs/asana-teams
12
 * @see https://developers.asana.com/docs/team
13
 *
14
 * @immutable Teams cannot be altered via the API.
15
 *
16
 * @method string       getDescription      ()
17
 * @method string       getName             ()
18
 * @method Workspace    getOrganization     ()
19
 */
20
class Team extends AbstractEntity implements ImmutableInterface {
21
22
    const DIR = 'teams';
23
    const TYPE = 'team';
24
25
    protected const MAP = [
26
        'organization' => Workspace::class
27
    ];
28
29
    /**
30
     * @param User $user
31
     * @return $this
32
     */
33
    public function addUser (User $user) {
34
        $this->api->post("{$this}/addUser", ['user' => $user->getGid()]);
35
        return $this;
36
    }
37
38
    /**
39
     * The team's projects.
40
     *
41
     * @see https://developers.asana.com/docs/get-a-teams-projects
42
     *
43
     * @param array $filter
44
     * @return Project[]
45
     */
46
    public function getProjects (array $filter = Project::GET_ACTIVE) {
47
        return $this->api->loadAll($this, Project::class, "{$this}/projects", $filter);
48
    }
49
50
    public function getUrl (): string {
51
        return "https://app.asana.com/0/{$this->getGid()}/overview";
52
    }
53
54
    /**
55
     * The team's users.
56
     *
57
     * @see https://developers.asana.com/docs/get-users-in-a-team
58
     *
59
     * @return User[]
60
     */
61
    public function getUsers () {
62
        return $this->api->loadAll($this, User::class, "{$this}/users");
63
    }
64
65
    /**
66
     * @param User $user
67
     * @return $this
68
     */
69
    public function removeUser (User $user) {
70
        $this->api->post("{$this}/removeUser", ['user' => $user->getGid()]);
71
        return $this;
72
    }
73
}