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

Team   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Importance

Changes 3
Bugs 0 Features 0
Metric Value
eloc 11
c 3
b 0
f 0
dl 0
loc 39
rs 10
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __toString() 0 2 1
A removeUser() 0 3 1
A getUrl() 0 2 1
A getUsers() 0 2 1
A addUser() 0 3 1
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
}