Completed
Branch BUG/reg-status-change-recursio... (66d1a3)
by
unknown
16:58 queued 08:55
created

RestIncomingQueryParamContext   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
dl 0
loc 58
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getModel() 0 4 1
A getRequestedVersion() 0 4 1
A isWriting() 0 4 1
1
<?php
2
3
namespace EventEspresso\core\libraries\rest_api;
4
5
use EEM_Base;
6
7
/**
8
 * Class RestIncomingQueryParamContext
9
 *
10
 * DTO describing the context in which query parameters coming from the REST API (ie, querystring) are to be
11
 * interpreted. This is info that can be determined before even looking at what the query parameters are.
12
 * This is convenient when interpreting REST API query params and generating model query params.
13
 *
14
 * @package     Event Espresso
15
 * @author         Mike Nelson
16
 * @since         4.9.72.p
17
 *
18
 */
19
class RestIncomingQueryParamContext
20
{
21
    /**
22
     * @var EEM_Base
23
     */
24
    private $model;
25
    /**
26
     * @var string
27
     */
28
    private $requested_version;
29
    /**
30
     * @var boolean
31
     */
32
    private $writing;
33
34
    /**
35
     * RestIncomingQueryParamContext constructor.
36
     * @param EEM_Base $model
37
     * @param string $requested_version
38
     * @param boolean $writing
39
     */
40
    public function __construct(EEM_Base $model, $requested_version, $writing)
41
    {
42
        $this->model = $model;
43
        $this->requested_version = (string) $requested_version;
44
        $this->writing = filter_var($writing, FILTER_VALIDATE_BOOLEAN);
45
    }
46
47
    /**
48
     * Gets the model currently being requested, eg class EEM_Event
49
     * @since 4.9.72.p
50
     * @return EEM_Base
51
     */
52
    public function getModel()
53
    {
54
        return $this->model;
55
    }
56
57
    /**
58
     * Gets the version being requested, eg 4.8.36
59
     * @since 4.9.72.p
60
     * @return string
61
     */
62
    public function getRequestedVersion()
63
    {
64
        return $this->requested_version;
65
    }
66
67
    /**
68
     * Gets if the current request is for a writing request or just simple read
69
     * @since 4.9.72.p
70
     * @return bool
71
     */
72
    public function isWriting()
73
    {
74
        return $this->writing;
75
    }
76
}
77
// End of file RestIncomingQueryParamContext.php
78
// Location: EventEspresso\core\libraries\rest_api/RestIncomingQueryParamContext.php
79