Total Complexity | 15 |
Total Lines | 74 |
Duplicated Lines | 0 % |
Coverage | 0% |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
9 | trait HasExecutionMethodsTrait |
||
10 | { |
||
11 | |||
12 | /** |
||
13 | * @return bool |
||
14 | */ |
||
15 | public function execute() |
||
16 | { |
||
17 | if ($this->submited()) { |
||
18 | return $this->processRequest(); |
||
19 | } |
||
20 | |||
21 | return false; |
||
22 | } |
||
23 | |||
24 | /** |
||
25 | * @return bool |
||
26 | */ |
||
27 | public function submited() |
||
28 | { |
||
29 | $request = $this->getAttrib('method') == 'post' ? $_POST : $_GET; |
||
|
|||
30 | if (count($request)) { |
||
31 | return true; |
||
32 | } |
||
33 | |||
34 | return false; |
||
35 | } |
||
36 | |||
37 | /** |
||
38 | * @return bool |
||
39 | */ |
||
40 | public function processRequest() |
||
41 | { |
||
42 | if ($this->validate()) { |
||
43 | $this->process(); |
||
44 | |||
45 | return true; |
||
46 | } |
||
47 | |||
48 | return false; |
||
49 | } |
||
50 | |||
51 | /** |
||
52 | * @return bool |
||
53 | */ |
||
54 | public function validate() |
||
55 | { |
||
56 | $request = $this->getAttrib('method') == 'post' ? $_POST : $_GET; |
||
57 | $this->getDataFromRequest($request); |
||
58 | $this->processValidation(); |
||
59 | |||
60 | return $this->isValid(); |
||
61 | } |
||
62 | |||
63 | public function processValidation() |
||
69 | } |
||
70 | } |
||
71 | } |
||
72 | |||
73 | /** |
||
74 | * @return bool |
||
75 | */ |
||
76 | public function isValid() |
||
77 | { |
||
78 | return count($this->getErrors()) > 0 ? false : true; |
||
79 | } |
||
80 | |||
81 | public function process() |
||
83 | } |
||
84 | } |
||
85 |