| Conditions | 5 |
| Paths | 5 |
| Total Lines | 121 |
| Code Lines | 79 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 56 | public function doExport() |
||
| 57 | { |
||
| 58 | $def = [ |
||
| 59 | ['o_id', 'N', 10, 0], |
||
| 60 | ['o_uid', 'N', 10, 0], |
||
| 61 | ['o_date', 'D'], |
||
| 62 | ['o_state', 'N', 1, 0], |
||
| 63 | ['o_ip', 'C', 32], |
||
| 64 | ['o_lastname', 'C', 155], |
||
| 65 | ['o_firstnam', 'C', 155], |
||
| 66 | ['o_adress', 'C', 155], |
||
| 67 | ['o_zip', 'C', 30], |
||
| 68 | ['o_town', 'C', 155], |
||
| 69 | ['o_country', 'C', 3], |
||
| 70 | ['o_telephon', 'C', 30], |
||
| 71 | ['o_email', 'C', 155], |
||
| 72 | ['o_articles', 'N', 10, 0], |
||
| 73 | ['o_total', 'N', 10, 2], |
||
| 74 | ['o_shipping', 'N', 10, 2], |
||
| 75 | ['o_bill', 'L'], |
||
| 76 | ['o_password', 'C', 155], |
||
| 77 | ['o_text', 'C', 155], |
||
| 78 | ['o_cancel', 'C', 155], |
||
| 79 | ['c_id', 'N', 10, 0], |
||
| 80 | ['c_prod_id', 'N', 10, 0], |
||
| 81 | ['c_qte', 'N', 10, 0], |
||
| 82 | ['c_price', 'N', 10, 2], |
||
| 83 | ['c_o_id', 'N', 10, 0], |
||
| 84 | ['c_shipping', 'N', 10, 2], |
||
| 85 | ['c_pass', 'C', 155], |
||
| 86 | ]; |
||
| 87 | /* |
||
| 88 | * Correspondances |
||
| 89 | * cmd_id o_id |
||
| 90 | * cmd_uid o_uid |
||
| 91 | * cmd_date o_date |
||
| 92 | * cmd_state o_state |
||
| 93 | * cmd_ip o_ip |
||
| 94 | * cmd_lastname o_lastname |
||
| 95 | * cmd_firstname o_firstnam |
||
| 96 | * cmd_adress o_adress |
||
| 97 | * cmd_zip o_zip |
||
| 98 | * cmd_town o_town |
||
| 99 | * cmd_country o_country |
||
| 100 | * cmd_telephone o_telephon |
||
| 101 | * cmd_email o_email |
||
| 102 | * cmd_articles_count o_articles |
||
| 103 | * cmd_total o_total |
||
| 104 | * cmd_shipping o_shipping |
||
| 105 | * cmd_bill o_bill |
||
| 106 | * cmd_password o_password |
||
| 107 | * cmd_text o_text |
||
| 108 | * cmd_cancel o_cancel |
||
| 109 | * caddy_id c_id |
||
| 110 | * caddy_product_id c_prod_id |
||
| 111 | * caddy_qte c_qte |
||
| 112 | * caddy_price c_price |
||
| 113 | * caddy_cmd_id c_o_id |
||
| 114 | * caddy_shipping c_shipping |
||
| 115 | * caddy_pass c_pass |
||
| 116 | */ |
||
| 117 | $db = \XoopsDatabaseFactory::getDatabaseConnection(); |
||
| 118 | $caddyHandler = new Oledrion\CaddyHandler($db); |
||
| 119 | $commandsHandler = new Oledrion\CommandsHandler($db); |
||
| 120 | if (!dbase_create($this->folder . '/' . $this->filename, $def)) { |
||
|
|
|||
| 121 | $this->success = false; |
||
| 122 | |||
| 123 | return false; |
||
| 124 | } |
||
| 125 | $dbf = dbase_open($this->folder . '/' . $this->filename, 2); |
||
| 126 | if (false === $dbf) { |
||
| 127 | $this->success = false; |
||
| 128 | |||
| 129 | return false; |
||
| 130 | } |
||
| 131 | |||
| 132 | $criteria = new \CriteriaCompo(); |
||
| 133 | $criteria->add(new \Criteria('cmd_id', 0, '<>')); |
||
| 134 | $criteria->add(new \Criteria('cmd_state', $this->orderType, '=')); |
||
| 135 | $criteria->setSort('cmd_date'); |
||
| 136 | $criteria->setOrder('DESC'); |
||
| 137 | $orders = $commandsHandler->getObjects($criteria); |
||
| 138 | foreach ($orders as $order) { |
||
| 139 | $carts = []; |
||
| 140 | $carts = $caddyHandler->getObjects(new \Criteria('caddy_cmd_id', $order->getVar('cmd_id'), '=')); |
||
| 141 | foreach ($carts as $cart) { |
||
| 142 | dbase_add_record($dbf, [ |
||
| 143 | $order->getVar('cmd_id'), |
||
| 144 | $order->getVar('cmd_uid'), |
||
| 145 | date('Ymd', strtotime($order->getVar('cmd_date'))), |
||
| 146 | $order->getVar('cmd_state'), |
||
| 147 | $order->getVar('cmd_ip'), |
||
| 148 | $order->getVar('cmd_lastname'), |
||
| 149 | $order->getVar('cmd_firstname'), |
||
| 150 | $order->getVar('cmd_adress'), |
||
| 151 | $order->getVar('cmd_zip'), |
||
| 152 | $order->getVar('cmd_town'), |
||
| 153 | $order->getVar('cmd_country'), |
||
| 154 | $order->getVar('cmd_telephone'), |
||
| 155 | $order->getVar('cmd_email'), |
||
| 156 | $order->getVar('cmd_articles_count'), |
||
| 157 | $order->getVar('cmd_total'), |
||
| 158 | $order->getVar('cmd_shipping'), |
||
| 159 | $order->getVar('cmd_bill'), |
||
| 160 | $order->getVar('cmd_password'), |
||
| 161 | $order->getVar('cmd_text'), |
||
| 162 | $order->getVar('cmd_cancel'), |
||
| 163 | $cart->getVar('caddy_id'), |
||
| 164 | $cart->getVar('caddy_product_id'), |
||
| 165 | $cart->getVar('caddy_qte'), |
||
| 166 | $cart->getVar('caddy_price'), |
||
| 167 | $cart->getVar('caddy_cmd_id'), |
||
| 168 | $cart->getVar('caddy_shipping'), |
||
| 169 | $cart->getVar('caddy_pass'), |
||
| 170 | ]); |
||
| 171 | } |
||
| 172 | } |
||
| 173 | dbase_close($dbf); |
||
| 174 | $this->success = true; |
||
| 175 | |||
| 176 | return true; |
||
| 177 | } |
||
| 204 |