Completed
Push — master ( 686ecf...037cc5 )
by Guillermo A.
09:28
created

TasksRepository   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 17
dl 0
loc 57
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A findCompleted() 0 5 1
A findAssigned() 0 5 1
A findUpcoming() 0 5 1
A findAll() 0 5 1
A findToday() 0 5 1
1
<?php
2
3
namespace Guillermoandrae\Highrise\Repositories;
4
5
use Guillermoandrae\Common\CollectionInterface;
6
7
class TasksRepository extends AbstractRelationalRepository
8
{
9
    use UnsearchableRepositoryTrait;
10
11
    public function findAll(array $filters = []): CollectionInterface
12
    {
13
        $uri = sprintf('/%s/all.xml', $this->getName());
14
        $results = $this->getAdapter()->request('GET', $uri, ['query' => $filters]);
15
        return $this->hydrate($results);
16
    }
17
18
    /**
19
     * Returns all upcoming tasks assigned to the authenticated user.
20
     *
21
     * @return CollectionInterface
22
     */
23
    public function findUpcoming(): CollectionInterface
24
    {
25
        $uri = sprintf('/%s/upcoming.xml', $this->getName());
26
        $results = $this->getAdapter()->request('GET', $uri);
27
        return $this->hydrate($results);
28
    }
29
30
    /**
31
     * Returns all assigned tasks assigned to the authenticated user.
32
     *
33
     * @return CollectionInterface
34
     */
35
    public function findAssigned(): CollectionInterface
36
    {
37
        $uri = sprintf('/%s/assigned.xml', $this->getName());
38
        $results = $this->getAdapter()->request('GET', $uri);
39
        return $this->hydrate($results);
40
    }
41
42
    /**
43
     * Returns all completed tasks assigned to the authenticated user.
44
     *
45
     * @return CollectionInterface
46
     */
47
    public function findCompleted(): CollectionInterface
48
    {
49
        $uri = sprintf('/%s/completed.xml', $this->getName());
50
        $results = $this->getAdapter()->request('GET', $uri);
51
        return $this->hydrate($results);
52
    }
53
54
    /**
55
     * Returns all of today's tasks assigned to the authenticated user.
56
     *
57
     * @return CollectionInterface
58
     */
59
    public function findToday(): CollectionInterface
60
    {
61
        $uri = sprintf('/%s/today.xml', $this->getName());
62
        $results = $this->getAdapter()->request('GET', $uri);
63
        return $this->hydrate($results);
64
    }
65
}
66