Tag::getTasks()   A
last analyzed

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 1
dl 0
loc 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Helix\Asana;
4
5
use Helix\Asana\Base\AbstractEntity;
6
use Helix\Asana\Base\AbstractEntity\CrudTrait;
7
use IteratorAggregate;
8
use Traversable;
9
10
/**
11
 * A tag.
12
 *
13
 * @see https://developers.asana.com/docs/asana-tags
14
 * @see https://developers.asana.com/docs/tag
15
 *
16
 * @see Workspace::newTag()
17
 *
18
 * @method $this        setWorkspace    (Workspace $workspace) @depends create-only
19
 *
20
 * @method string       getColor        ()
21
 * @method string       getCreatedAt    () RFC3339x
22
 * @method User[]       getFollowers    ()
23
 * @method string       getName         ()
24
 * @method Workspace    getWorkspace    ()
25
 *
26
 * @method bool         hasFollowers    ()
27
 *
28
 * @method $this        setColor        (string $color)
29
 * @method $this        setName         (string $name)
30
 *
31
 * @method User[]       selectFollowers (callable $filter) `fn( User $user ): bool`
32
 */
33
class Tag extends AbstractEntity implements IteratorAggregate {
34
35
    use CrudTrait;
36
37
    const DIR = 'tags';
38
    const TYPE = 'tag';
39
40
    protected const MAP = [
41
        'followers' => [User::class],
42
        'workspace' => Workspace::class
43
    ];
44
45
    /**
46
     * @param array $filter
47
     * @return Traversable|Task[]
48
     */
49
    public function getIterator (array $filter = Task::GET_INCOMPLETE) {
50
        return $this->api->loadEach($this, Task::class, "{$this}/tasks", $filter);
51
    }
52
53
    /**
54
     * @param array $filter
55
     * @return Task[]
56
     */
57
    public function getTasks (array $filter = Task::GET_INCOMPLETE) {
58
        return iterator_to_array($this->getIterator($filter));
59
    }
60
}