Space::folders()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 1
c 1
b 0
f 0
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Spinen\ClickUp;
4
5
use Spinen\ClickUp\Exceptions\InvalidRelationshipException;
6
use Spinen\ClickUp\Exceptions\ModelNotFoundException;
7
use Spinen\ClickUp\Exceptions\NoClientException;
8
use Spinen\ClickUp\Support\Collection;
9
use Spinen\ClickUp\Support\Model;
10
use Spinen\ClickUp\Support\Relations\ChildOf;
11
use Spinen\ClickUp\Support\Relations\HasMany;
12
13
/**
14
 * Class Space
15
 *
16
 * @package Spinen\ClickUp
17
 *
18
 * @property array $features
19
 * @property boolean $archived
20
 * @property boolean $multiple_assignees
21
 * @property boolean $private
22
 * @property Collection $folders
23
 * @property Collection $members
24
 * @property Collection $statuses
25
 * @property Collection $tags
26
 * @property Collection $taskLists
27
 * @property Collection $views
28
 * @property integer $id
29
 * @property string $name
30
 * @property Team $team
31
 */
32
class Space extends Model
33
{
34
    /**
35
     * The attributes that should be cast to native types.
36
     *
37
     * @var array
38
     */
39
    protected $casts = [
40
        'archived'           => 'boolean',
41
        'id'                 => 'integer',
42
        'multiple_assignees' => 'boolean',
43
        'private'            => 'boolean',
44
    ];
45
46
    /**
47
     * Path to API endpoint.
48
     *
49
     * @var string
50
     */
51
    protected $path = '/space';
52
53
    /**
54
     * Accessor for Members.
55
     *
56
     * @param array $members
57
     *
58
     * @return Collection
59
     * @throws NoClientException
60
     */
61 1
    public function getMembersAttribute(array $members): Collection
62
    {
63 1
        return $this->givenMany(Member::class, $members, true);
64
    }
65
66
    /**
67
     * Accessor for Statuses.
68
     *
69
     * @param array $statuses
70
     *
71
     * @return Collection
72
     * @throws NoClientException
73
     */
74 1
    public function getStatusesAttribute(array $statuses): Collection
75
    {
76 1
        return $this->givenMany(Status::class, $statuses);
77
    }
78
79
    /**
80
     * @return HasMany
81
82
     * @throws InvalidRelationshipException
83
     * @throws ModelNotFoundException
84
     * @throws NoClientException
85
     */
86 1
    public function folders(): HasMany
87
    {
88 1
        return $this->hasMany(Folder::class);
89
    }
90
91
    /**
92
     * @return HasMany
93
94
     * @throws InvalidRelationshipException
95
     * @throws ModelNotFoundException
96
     * @throws NoClientException
97
     */
98 1
    public function lists(): HasMany
99
    {
100 1
        return $this->hasMany(TaskList::class);
101
    }
102
103
    /**
104
     * @return HasMany
105
106
     * @throws InvalidRelationshipException
107
     * @throws ModelNotFoundException
108
     * @throws NoClientException
109
     */
110 1
    public function tags(): HasMany
111
    {
112 1
        return $this->hasMany(Tag::class);
113
    }
114
115
    /**
116
     * @return ChildOf
117
     * @throws InvalidRelationshipException
118
     * @throws ModelNotFoundException
119
     * @throws NoClientException
120
     */
121 1
    public function team(): ChildOf
122
    {
123 1
        return $this->childOf(Team::class);
124
    }
125
126
    /**
127
     * @return HasMany
128
129
     * @throws InvalidRelationshipException
130
     * @throws ModelNotFoundException
131
     * @throws NoClientException
132
     */
133 1
    public function views(): HasMany
134
    {
135 1
        return $this->hasMany(View::class);
136
    }
137
}
138