Folder::space()   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 Folder
15
 *
16
 * @package Spinen\ClickUp
17
 *
18
 * @property boolean $archived
19
 * @property boolean $hidden
20
 * @property boolean $override_statuses
21
 * @property Collection $lists
22
 * @property Collection $statuses
23
 * @property Collection $views
24
 * @property float $orderindex
25
 * @property integer $id
26
 * @property integer $task_count
27
 * @property Space $space
28
 * @property string $name
29
 */
30
class Folder extends Model
31
{
32
    /**
33
     * The attributes that should be cast to native types.
34
     *
35
     * @var array
36
     */
37
    protected $casts = [
38
        'archived'          => 'boolean',
39
        'hidden'            => 'boolean',
40
        'id'                => 'integer',
41
        'orderindex'        => 'float',
42
        'override_statuses' => 'boolean',
43
        'task_count'        => 'integer',
44
    ];
45
46
    /**
47
     * Path to API endpoint.
48
     *
49
     * @var string
50
     */
51
    protected $path = '/folder';
52
53
    /**
54
     * Accessor for Statuses.
55
     *
56
     * @param array $statuses
57
     *
58
     * @return Collection
59
     * @throws NoClientException
60
     */
61 1
    public function getStatusesAttribute(array $statuses): Collection
62
    {
63 1
        return $this->givenMany(Status::class, $statuses);
64
    }
65
66
    /**
67
     * Accessor for Lists.
68
     *
69
     * @param array $lists
70
     *
71
     * @return Collection
72
     * @throws NoClientException
73
     */
74 1
    public function getListsAttribute(array $lists): Collection
75
    {
76 1
        return $this->givenMany(TaskList::class, $lists);
77
    }
78
79
    /**
80
     * @return ChildOf
81
     * @throws InvalidRelationshipException
82
     * @throws ModelNotFoundException
83
     * @throws NoClientException
84
     */
85 1
    public function space(): ChildOf
86
    {
87 1
        return $this->childOf(Space::class);
88
    }
89
90
    /**
91
     * @return HasMany
92
93
     * @throws InvalidRelationshipException
94
     * @throws ModelNotFoundException
95
     * @throws NoClientException
96
     */
97 1
    public function views(): HasMany
98
    {
99 1
        return $this->hasMany(View::class);
100
    }
101
}
102