StateDocumentsFilter   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 2
dl 0
loc 57
rs 10
c 0
b 0
f 0

5 Methods

Rating   Name   Duplication   Size   Complexity  
A byActivity() 0 6 1
A byAgent() 0 6 1
A byRegistration() 0 6 1
A since() 0 6 1
A getFilter() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the xAPI package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\XApi\Model;
13
14
/**
15
 * Filter to apply on GET requests to the states API.
16
 *
17
 * @author Jérôme Parmentier <[email protected]>
18
 */
19
class StateDocumentsFilter
20
{
21
    /**
22
     * @var array The generated filter
23
     */
24
    private $filter = array();
25
26
    /**
27
     * Filter by an Activity.
28
     */
29
    public function byActivity(Activity $activity): self
30
    {
31
        $this->filter['activity'] = $activity->getId()->getValue();
32
33
        return $this;
34
    }
35
36
    /**
37
     * Filters by an Agent.
38
     */
39
    public function byAgent(Agent $agent): self
40
    {
41
        $this->filter['agent'] = $agent;
42
43
        return $this;
44
    }
45
46
    /**
47
     * Filters for State documents matching the given registration id.
48
     */
49
    public function byRegistration(string $registration): self
50
    {
51
        $this->filter['registration'] = $registration;
52
53
        return $this;
54
    }
55
56
    /**
57
     * Filters for State documents stored since the specified timestamp (exclusive).
58
     */
59
    public function since(\DateTime $timestamp): self
60
    {
61
        $this->filter['since'] = $timestamp->format('c');
62
63
        return $this;
64
    }
65
66
    /**
67
     * Returns the generated filter.
68
     *
69
     * @return array The filter
70
     */
71
    public function getFilter(): array
72
    {
73
        return $this->filter;
74
    }
75
}
76