From 0caff545a950f081519db65d533070b10dcc2281 Mon Sep 17 00:00:00 2001 From: Alex Tselegidis Date: Sun, 17 Jul 2016 13:07:59 +0200 Subject: [PATCH] Removed unnecessary constructor methods from model classes. --- src/application/models/Admins_model.php | 7 ------ src/application/models/Appointments_model.php | 19 +++++---------- src/application/models/Customers_model.php | 23 +++++++------------ src/application/models/Providers_model.php | 7 ------ src/application/models/Roles_model.php | 7 ------ src/application/models/Secretaries_model.php | 7 ------ src/application/models/Services_model.php | 15 ++++-------- src/application/models/Settings_model.php | 15 ++++-------- src/application/models/User_model.php | 21 ++++++++--------- 9 files changed, 31 insertions(+), 90 deletions(-) diff --git a/src/application/models/Admins_model.php b/src/application/models/Admins_model.php index f002a32e..0c371016 100644 --- a/src/application/models/Admins_model.php +++ b/src/application/models/Admins_model.php @@ -33,13 +33,6 @@ * @package Models */ class Admins_Model extends CI_Model { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - /** * Add (insert or update) an admin user record into database. * diff --git a/src/application/models/Appointments_model.php b/src/application/models/Appointments_model.php index a4636573..25ec2ae1 100644 --- a/src/application/models/Appointments_model.php +++ b/src/application/models/Appointments_model.php @@ -17,13 +17,6 @@ * @package Models */ class Appointments_Model extends CI_Model { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - /** * Add an appointment record to the database. * @@ -68,7 +61,7 @@ class Appointments_Model extends CI_Model { || !isset($appointment['id_users_customer']) || !isset($appointment['id_services'])) { throw new Exception('Not all appointment field values ' - . 'are provided : ' . print_r($appointment, TRUE)); + . 'are provided: ' . print_r($appointment, TRUE)); } $num_rows = $this->db->get_where('ea_appointments', array( @@ -253,7 +246,7 @@ class Appointments_Model extends CI_Model { public function get_row($appointment_id) { if (!is_numeric($appointment_id)) { throw new Exception('Invalid argument given. Expected ' - . 'integer for the $appointment_id : ' . $appointment_id); + . 'integer for the $appointment_id: ' . $appointment_id); } return $this->db->get_where('ea_appointments', array('id' => $appointment_id))->row_array(); @@ -269,18 +262,18 @@ class Appointments_Model extends CI_Model { public function get_value($field_name, $appointment_id) { if (!is_numeric($appointment_id)) { throw new Exception('Invalid argument given, expected ' - . 'integer for the $appointment_id : ' . $appointment_id); + . 'integer for the $appointment_id: ' . $appointment_id); } if (!is_string($field_name)) { throw new Exception('Invalid argument given, expected ' - . 'string for the $field_name : ' . $field_name); + . 'string for the $field_name: ' . $field_name); } if ($this->db->get_where('ea_appointments', array('id' => $appointment_id))->num_rows() == 0) { throw new Exception('The record with the provided id ' - . 'does not exist in the database : ' . $appointment_id); + . 'does not exist in the database: ' . $appointment_id); } $row_data = $this->db->get_where('ea_appointments', @@ -288,7 +281,7 @@ class Appointments_Model extends CI_Model { if (!isset($row_data[$field_name])) { throw new Exception('The given field name does not ' - . 'exist in the database : ' . $field_name); + . 'exist in the database: ' . $field_name); } return $row_data[$field_name]; diff --git a/src/application/models/Customers_model.php b/src/application/models/Customers_model.php index e50d9e91..df3895bb 100644 --- a/src/application/models/Customers_model.php +++ b/src/application/models/Customers_model.php @@ -17,13 +17,6 @@ * @package Models */ class Customers_Model extends CI_Model { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - /** * Add a customer record to the database. * @@ -148,7 +141,7 @@ class Customers_Model extends CI_Model { */ public function find_record_id($customer) { if (!isset($customer['email'])) { - throw new Exception('Customer\'s email was not provided : ' + throw new Exception('Customer\'s email was not provided: ' . print_r($customer, TRUE)); } @@ -191,13 +184,13 @@ class Customers_Model extends CI_Model { if (!isset($customer['last_name']) || !isset($customer['email']) || !isset($customer['phone_number'])) { - throw new Exception('Not all required fields are provided : ' + throw new Exception('Not all required fields are provided: ' . print_r($customer, TRUE)); } // Validate email address if (!filter_var($customer['email'], FILTER_VALIDATE_EMAIL)) { - throw new Exception('Invalid email address provided : ' + throw new Exception('Invalid email address provided: ' . $customer['email']); } @@ -230,7 +223,7 @@ class Customers_Model extends CI_Model { */ public function delete($customer_id) { if (!is_numeric($customer_id)) { - throw new Exception('Invalid argument type $customer_id : ' . $customer_id); + throw new Exception('Invalid argument type $customer_id: ' . $customer_id); } $num_rows = $this->db->get_where('ea_users', array('id' => $customer_id))->num_rows(); @@ -266,25 +259,25 @@ class Customers_Model extends CI_Model { */ public function get_value($field_name, $customer_id) { if (!is_numeric($customer_id)) { - throw new Exception('Invalid argument provided as $customer_id : ' + throw new Exception('Invalid argument provided as $customer_id: ' . $customer_id); } if (!is_string($field_name)) { - throw new Exception('$field_name argument is not a string : ' + throw new Exception('$field_name argument is not a string: ' . $field_name); } if ($this->db->get_where('ea_users', array('id' => $customer_id))->num_rows() == 0) { throw new Exception('The record with the $customer_id argument ' - . 'does not exist in the database : ' . $customer_id); + . 'does not exist in the database: ' . $customer_id); } $row_data = $this->db->get_where('ea_users', array('id' => $customer_id) )->row_array(); if (!isset($row_data[$field_name])) { throw new Exception('The given $field_name argument does not' - . 'exist in the database : ' . $field_name); + . 'exist in the database: ' . $field_name); } $customer = $this->db->get_where('ea_users', array('id' => $customer_id))->row_array(); diff --git a/src/application/models/Providers_model.php b/src/application/models/Providers_model.php index 455089e1..b11271a8 100644 --- a/src/application/models/Providers_model.php +++ b/src/application/models/Providers_model.php @@ -45,13 +45,6 @@ * @package Models */ class Providers_Model extends CI_Model { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - /** * Add (insert - update) a service provider record. * diff --git a/src/application/models/Roles_model.php b/src/application/models/Roles_model.php index 9079c8fe..517f1102 100644 --- a/src/application/models/Roles_model.php +++ b/src/application/models/Roles_model.php @@ -17,13 +17,6 @@ * @package Models */ class Roles_Model extends CI_Model { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - /** * Get the record id of a particular role. * diff --git a/src/application/models/Secretaries_model.php b/src/application/models/Secretaries_model.php index f08a123f..802a9bfd 100644 --- a/src/application/models/Secretaries_model.php +++ b/src/application/models/Secretaries_model.php @@ -34,13 +34,6 @@ * @package Models */ class Secretaries_Model extends CI_Model { - /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - /** * Add (insert or update) a secretary user record into database. * diff --git a/src/application/models/Services_model.php b/src/application/models/Services_model.php index e9656d05..c3c840ab 100644 --- a/src/application/models/Services_model.php +++ b/src/application/models/Services_model.php @@ -17,13 +17,6 @@ * @package Models */ class Services_Model extends CI_Model { - /** - * Class Constructor - */ - function __construct() { - parent::__construct(); - } - /** * Add (insert or update) a service record on the database * @@ -220,20 +213,20 @@ class Services_Model extends CI_Model { */ public function get_value($field_name, $service_id) { if (!is_numeric($service_id)) { - throw new Exception('Invalid argument provided as $service_id : ' . $service_id); + throw new Exception('Invalid argument provided as $service_id: ' . $service_id); } if (!is_string($field_name)) { - throw new Exception('$field_name argument is not a string : ' . $field_name); + throw new Exception('$field_name argument is not a string: ' . $field_name); } if ($this->db->get_where('ea_services', array('id' => $service_id))->num_rows() == 0) { - throw new Exception('The record with the $service_id argument does not exist in the database : ' . $service_id); + throw new Exception('The record with the $service_id argument does not exist in the database: ' . $service_id); } $row_data = $this->db->get_where('ea_services', array('id' => $service_id))->row_array(); if (!isset($row_data[$field_name])) { - throw new Exception('The given $field_name argument does not exist in the database : ' . $field_name); + throw new Exception('The given $field_name argument does not exist in the database: ' . $field_name); } $setting = $this->db->get_where('ea_services', array('id' => $service_id))->row_array(); diff --git a/src/application/models/Settings_model.php b/src/application/models/Settings_model.php index 4f4e6d97..7f8379e0 100644 --- a/src/application/models/Settings_model.php +++ b/src/application/models/Settings_model.php @@ -17,13 +17,6 @@ * @package Models */ class Settings_Model extends CI_Model { - /** - * Class Constructor - */ - function __construct() { - parent::__construct(); - } - /** * Get setting value from database. * @@ -37,11 +30,11 @@ class Settings_Model extends CI_Model { */ public function get_setting($name) { if (!is_string($name)) { // Check argument type. - throw new Exception('$name argument is not a string : ' . $name); + throw new Exception('$name argument is not a string: ' . $name); } if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) { // Check if setting exists in db. - throw new Exception('$name setting does not exist in database : ' . $name); + throw new Exception('$name setting does not exist in database: ' . $name); } $query = $this->db->get_where('ea_settings', array('name' => $name)); @@ -63,7 +56,7 @@ class Settings_Model extends CI_Model { */ public function set_setting($name, $value) { if (!is_string($name)) { - throw new Exception('$name argument is not a string : ' . $name); + throw new Exception('$name argument is not a string: ' . $name); } $query = $this->db->get_where('ea_settings', array('name' => $name)); @@ -99,7 +92,7 @@ class Settings_Model extends CI_Model { */ public function remove_setting($name) { if (!is_string($name)) { - throw new Exception('$name is not a string : ' . $name); + throw new Exception('$name is not a string: ' . $name); } if ($this->db->get_where('ea_settings', array('name' => $name))->num_rows() == 0) { diff --git a/src/application/models/User_model.php b/src/application/models/User_model.php index dc793755..89d49c17 100644 --- a/src/application/models/User_model.php +++ b/src/application/models/User_model.php @@ -20,18 +20,13 @@ */ class User_Model extends CI_Model { /** - * Class Constructor - */ - public function __construct() { - parent::__construct(); - } - - /** - * Returns the user settings from the database. + * Returns the user from the database for the "settings" page. * - * @param numeric $user_id User record id of which the settings will be returned. + * @param numeric $user_id User record id. * - * @return array Returns an array with user settings. + * @return array Returns an array with user data. + * + * @todo Refactor this method as it does not do as it states. */ public function get_settings($user_id) { $user = $this->db->get_where('ea_users', array('id' => $user_id))->row_array(); @@ -41,11 +36,13 @@ class User_Model extends CI_Model { } /** - * This method saves the user settings into the database. + * This method saves the user record into the database (used in backend settings page). * - * @param array $user Contains the current users settings. + * @param array $user Contains the current users data. * * @return bool Returns the operation result. + * + * @todo Refactor this method as it does not do as it states. */ public function save_settings($user) { $user_settings = $user['settings'];