Completed
Push — master ( f42a52...0a9499 )
by Thierry
02:50 queued 01:16
created

Callback::invalid()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
nc 2
nop 1
dl 0
loc 8
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * Callbacks.php - Jaxon request callbacks
5
 *
6
 * @package jaxon-core
7
 * @author Thierry Feuzeu <[email protected]>
8
 * @copyright 2017 Thierry Feuzeu <[email protected]>
9
 * @license https://opensource.org/licenses/BSD-3-Clause BSD 3-Clause License
10
 * @link https://github.com/jaxon-php/jaxon-core
11
 */
12
13
namespace Jaxon\Request\Handler;
14
15
class Callback
16
{
17
    /**
18
     * The callback to run before processing the request
19
     *
20
     * @var Callable
21
     */
22
    protected $xBeforeCallback = null;
23
24
    /**
25
     * The callback to run afteer processing the request
26
     *
27
     * @var Callable
28
     */
29
    protected $xAfterCallback = null;
30
31
    /**
32
     * The callback to run in case of invalid request
33
     *
34
     * @var Callable
35
     */
36
    protected $xInvalidCallback = null;
37
38
    /**
39
     * The callback to run in case of error
40
     *
41
     * @var Callable
42
     */
43
    protected $xErrorCallback = null;
44
45
    /**
46
     * Get or set the pre-request processing callback.
47
     *
48
     * @param Callable|null  $xCallable               The callback function
49
     *
50
     * @return void
51
     */
52
    public function before($xCallable = null)
53
    {
54
        if($xCallable === null)
55
        {
56
            return $this->xBeforeCallback;
57
        }
58
        $this->xBeforeCallback = $xCallable;
59
    }
60
61
    /**
62
     * Get or set the post-request processing callback.
63
     *
64
     * @param Callable|null  $xCallable               The callback function
65
     *
66
     * @return void
67
     */
68
    public function after($xCallable = null)
69
    {
70
        if($xCallable === null)
71
        {
72
            return $this->xAfterCallback;
73
        }
74
        $this->xAfterCallback = $xCallable;
75
    }
76
77
    /**
78
     * Get or set the invalid request callback.
79
     *
80
     * @param Callable|null  $xCallable               The callback function
81
     *
82
     * @return void
83
     */
84
    public function invalid($xCallable = null)
85
    {
86
        if($xCallable === null)
87
        {
88
            return $this->xInvalidCallback;
89
        }
90
        $this->xInvalidCallback = $xCallable;
91
    }
92
93
    /**
94
     * Get or set the processing error callback.
95
     *
96
     * @param Callable|null  $xCallable               The callback function
97
     *
98
     * @return void
99
     */
100
    public function error($xCallable = null)
101
    {
102
        if($xCallable === null)
103
        {
104
            return $this->xErrorCallback;
105
        }
106
        $this->xErrorCallback = $xCallable;
107
    }
108
}
109