1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace plunner\Policies; |
4
|
|
|
|
5
|
|
|
use plunner\PolicyCheckable; |
6
|
|
|
use plunner\Timeslot; |
7
|
|
|
|
8
|
|
|
/** |
9
|
|
|
* Class TimeslotPolicy |
10
|
|
|
* @package plunner\Policies |
11
|
|
|
* @author Claudio Cardinale <[email protected]> |
12
|
|
|
* @copyright 2015 Claudio Cardinale |
13
|
|
|
* @version 1.0.0 |
14
|
|
|
*/ |
15
|
|
|
class TimeslotPolicy |
16
|
|
|
{ |
17
|
|
|
/** |
18
|
|
|
* Create a new policy instance. |
19
|
|
|
* |
20
|
|
|
* @return void |
|
|
|
|
21
|
|
|
*/ |
22
|
12 |
|
public function __construct() |
23
|
|
|
{ |
24
|
|
|
// |
25
|
12 |
|
} |
26
|
|
|
|
27
|
|
|
/** |
28
|
|
|
* @param PolicyCheckable $policyCheckable |
29
|
|
|
* @param Timeslot $timeslot |
30
|
|
|
* @return bool |
31
|
|
|
*/ |
32
|
|
|
public function index(PolicyCheckable $policyCheckable, Timeslot $timeslot) |
33
|
|
|
{ |
34
|
|
|
return $this->userCheck($policyCheckable, $timeslot); |
35
|
|
|
} |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @param PolicyCheckable $policyCheckable |
39
|
|
|
* @param Timeslot $timeslot |
40
|
|
|
* @return bool |
41
|
|
|
*/ |
42
|
12 |
|
private function userCheck(PolicyCheckable $policyCheckable, Timeslot $timeslot) |
43
|
|
|
{ |
44
|
12 |
|
return $policyCheckable->verifyTimeslot($timeslot); |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @param PolicyCheckable $policyCheckable |
49
|
|
|
* @param Timeslot $timeslot |
50
|
|
|
* @return bool |
51
|
|
|
*/ |
52
|
|
|
public function store(PolicyCheckable $policyCheckable, Timeslot $timeslot) |
53
|
|
|
{ |
54
|
|
|
return $this->userCheck($policyCheckable, $timeslot); |
55
|
|
|
} |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @param PolicyCheckable $policyCheckable |
59
|
|
|
* @param Timeslot $timeslot |
60
|
|
|
* @return bool |
61
|
|
|
*/ |
62
|
3 |
|
public function update(PolicyCheckable $policyCheckable, Timeslot $timeslot) |
63
|
|
|
{ |
64
|
3 |
|
return $this->userCheck($policyCheckable, $timeslot); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param PolicyCheckable $policyCheckable |
69
|
|
|
* @param Timeslot $timeslot |
70
|
|
|
* @return bool |
71
|
|
|
*/ |
72
|
9 |
|
public function show(PolicyCheckable $policyCheckable, Timeslot $timeslot) |
73
|
|
|
{ |
74
|
9 |
|
$ret = $this->userCheck($policyCheckable, $timeslot); |
75
|
9 |
|
return $ret; |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* @param PolicyCheckable $policyCheckable |
80
|
|
|
* @param Timeslot $timeslot |
81
|
|
|
* @return bool |
82
|
|
|
*/ |
83
|
3 |
|
public function destroy(PolicyCheckable $policyCheckable, Timeslot $timeslot) |
84
|
|
|
{ |
85
|
3 |
|
return $this->userCheck($policyCheckable, $timeslot); |
86
|
|
|
} |
87
|
|
|
} |
88
|
|
|
|
Adding a
@return
annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.Please refer to the PHP core documentation on constructors.