Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * Should I be doing this?
- */
- class Service {
- private function connectLicenseDatabase() {
- //Some lines of code to connect to the license database
- return $dbh;
- }
- private function getUserDetails($order_id) {
- //Some lines of code to get user datails
- return $user_details
- }
- private function getPaidInvoiceFromOrder($order_id) {
- //Some lines of code to get the invoice id
- return $invoice_id
- }
- public function addLicense($params = array()) {
- $userDetails = $this->getUserDetails($params['order_id']);
- $bindings = array_merge($userDetails, $params);
- $bindings['invoice_id'] = $this->getPaidInvoiceFromOrder($params['order_id']);
- $dbh = $this->connectLicenseDatabase();
- $qry = $dbh->prepare(...);
- $qry->execute($bindings);
- return $qry->fetchAll(...);
- }
- }
- /*
- * Instead of this
- */
- class Service {
- public function addLicense($params = array()) {
- //Some lines of code to get user details
- $userDetails = array(...);
- //Some lines of code to get the invoice id
- $invoice_id = ...;
- //Some lines of code to connect to the DB
- $dbh = ...;
- $bindings = array_merge($userDetails, $params);
- $qry = $dbh->prepare(...);
- $qry->execute($bindings);
- return $qry->fetchAll(...);
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement