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