From 5229ed5767ede8b5f2111a771d51f043432f8e46 Mon Sep 17 00:00:00 2001 From: alextselegidis Date: Mon, 10 Oct 2016 17:46:29 +0200 Subject: [PATCH] Renamed engine type classes for PHP7 compatibility (fixes #204). --- src/application/controllers/Appointments.php | 22 ++++++++-------- src/application/controllers/Backend_api.php | 25 ++++++++++--------- src/application/controllers/User.php | 4 +-- .../controllers/api/v1/API_V1_Controller.php | 6 ++--- src/application/controllers/api/v1/Admins.php | 4 +-- .../controllers/api/v1/Appointments.php | 4 +-- .../controllers/api/v1/Availabilities.php | 6 ++--- .../controllers/api/v1/Categories.php | 4 +-- .../controllers/api/v1/Customers.php | 4 +-- .../controllers/api/v1/Providers.php | 4 +-- .../controllers/api/v1/Secretaries.php | 4 +-- .../controllers/api/v1/Services.php | 4 +-- .../controllers/api/v1/Settings.php | 2 +- .../controllers/api/v1/Unavailabilities.php | 4 +-- src/engine/Api/V1/Authorization.php | 8 +++--- src/engine/Api/V1/Response.php | 6 ++--- src/engine/Notifications/Email.php | 20 +++++++-------- .../Types/{String.php => Alphanumeric.php} | 2 +- src/engine/Types/{Bool.php => Boolean.php} | 2 +- src/engine/Types/{Float.php => Decimal.php} | 2 +- src/engine/Types/Email.php | 2 +- src/engine/Types/{Int.php => Integer.php} | 2 +- ...ptyString.php => NonEmptyAlphanumeric.php} | 2 +- .../{UnsignedInt.php => UnsignedInteger.php} | 2 +- src/engine/Types/Url.php | 2 +- test/php/engine/Api/V1/AuthorizationTest.php | 2 +- .../{StringTest.php => AlphanumericTest.php} | 6 ++--- .../Types/{BoolTest.php => BooleanTest.php} | 6 ++--- .../Types/{FloatTest.php => DecimalTest.php} | 6 ++--- .../Types/{IntTest.php => IntegerTest.php} | 8 +++--- ...gTest.php => NonEmptyAlphanumericTest.php} | 8 +++--- ...nedIntTest.php => UnsignedIntegerTest.php} | 8 +++--- 32 files changed, 96 insertions(+), 95 deletions(-) rename src/engine/Types/{String.php => Alphanumeric.php} (94%) rename src/engine/Types/{Bool.php => Boolean.php} (95%) rename src/engine/Types/{Float.php => Decimal.php} (95%) rename src/engine/Types/{Int.php => Integer.php} (95%) rename src/engine/Types/{NonEmptyString.php => NonEmptyAlphanumeric.php} (92%) rename src/engine/Types/{UnsignedInt.php => UnsignedInteger.php} (94%) rename test/php/engine/Types/{StringTest.php => AlphanumericTest.php} (84%) rename test/php/engine/Types/{BoolTest.php => BooleanTest.php} (86%) rename test/php/engine/Types/{FloatTest.php => DecimalTest.php} (86%) rename test/php/engine/Types/{IntTest.php => IntegerTest.php} (85%) rename test/php/engine/Types/{NonEmptyStringTest.php => NonEmptyAlphanumericTest.php} (82%) rename test/php/engine/Types/{UnsignedIntTest.php => UnsignedIntegerTest.php} (83%) diff --git a/src/application/controllers/Appointments.php b/src/application/controllers/Appointments.php index 6e7ac7c3..4a3b5940 100755 --- a/src/application/controllers/Appointments.php +++ b/src/application/controllers/Appointments.php @@ -11,7 +11,7 @@ * @since v1.0.0 * ---------------------------------------------------------------------------- */ -use \EA\Engine\Types\String; +use \EA\Engine\Types\Alphanumeric; use \EA\Engine\Types\Email; use \EA\Engine\Types\Url; @@ -203,7 +203,7 @@ class Appointments extends CI_Controller { if ($send_provider === TRUE) { $email->sendDeleteAppointment($appointment, $provider, $service, $customer, $company_settings, new Email($provider['email']), - new String($_POST['cancel_reason'])); + new Alphanumeric($_POST['cancel_reason'])); } $send_customer = filter_var($this->settings_model->get_setting('customer_notifications'), @@ -212,7 +212,7 @@ class Appointments extends CI_Controller { if ($send_customer === TRUE) { $email->sendDeleteAppointment($appointment, $provider, $service, $customer, $company_settings, new Email($customer['email']), - new String($_POST['cancel_reason'])); + new Alphanumeric($_POST['cancel_reason'])); } } catch(Exception $exc) { @@ -431,16 +431,16 @@ class Appointments extends CI_Controller { $email = new \EA\Engine\Notifications\Email($this, $this->config->config); if ($post_data['manage_mode'] == FALSE) { - $customer_title = new String($this->lang->line('appointment_booked')); - $customer_message = new String($this->lang->line('thank_you_for_appointment')); - $provider_title = new String($this->lang->line('appointment_added_to_your_plan')); - $provider_message = new String($this->lang->line('appointment_link_description')); + $customer_title = new Alphanumeric($this->lang->line('appointment_booked')); + $customer_message = new Alphanumeric($this->lang->line('thank_you_for_appointment')); + $provider_title = new Alphanumeric($this->lang->line('appointment_added_to_your_plan')); + $provider_message = new Alphanumeric($this->lang->line('appointment_link_description')); } else { - $customer_title = new String($this->lang->line('appointment_changes_saved')); - $customer_message = new String(''); - $provider_title = new String($this->lang->line('appointment_details_changed')); - $provider_message = new String(''); + $customer_title = new Alphanumeric($this->lang->line('appointment_changes_saved')); + $customer_message = new Alphanumeric(''); + $provider_title = new Alphanumeric($this->lang->line('appointment_details_changed')); + $provider_message = new Alphanumeric(''); } $customer_link = new Url(site_url('appointments/index/' . $appointment['hash'])); diff --git a/src/application/controllers/Backend_api.php b/src/application/controllers/Backend_api.php index d41d1fdb..1fcf8f4f 100644 --- a/src/application/controllers/Backend_api.php +++ b/src/application/controllers/Backend_api.php @@ -11,8 +11,9 @@ * @since v1.0.0 * ---------------------------------------------------------------------------- */ -use \EA\Engine\Types\String; -use \EA\Engine\Types\Email; +use \EA\Engine\Types\Decimal; +use \EA\Engine\Types\Alphanumeric; +use \EA\Engine\Types\Email; use \EA\Engine\Types\Url; /** @@ -295,15 +296,15 @@ class Backend_api extends CI_Controller { ->get_setting('notifications', $provider['id']); if (!$manage_mode) { - $customer_title = new String($this->lang->line('appointment_booked')); - $customer_message = new String($this->lang->line('thank_you_for_appointment')); - $provider_title = new String($this->lang->line('appointment_added_to_your_plan')); - $provider_message = new String($this->lang->line('appointment_link_description')); + $customer_title = new Alphanumeric($this->lang->line('appointment_booked')); + $customer_message = new Alphanumeric($this->lang->line('thank_you_for_appointment')); + $provider_title = new Alphanumeric($this->lang->line('appointment_added_to_your_plan')); + $provider_message = new Alphanumeric($this->lang->line('appointment_link_description')); } else { - $customer_title = new String($this->lang->line('appointment_changes_saved')); - $customer_message = new String(''); - $provider_title = new String($this->lang->line('appointment_details_changed')); - $provider_message = new String(''); + $customer_title = new Alphanumeric($this->lang->line('appointment_changes_saved')); + $customer_message = new Alphanumeric(''); + $provider_title = new Alphanumeric($this->lang->line('appointment_details_changed')); + $provider_message = new Alphanumeric(''); } $customer_link = new Url(site_url('appointments/index/' . $appointment['hash'])); @@ -410,7 +411,7 @@ class Backend_api extends CI_Controller { if ((bool)$send_provider === TRUE) { $email->sendDeleteAppointment($appointment, $provider, $service, $customer, $company_settings, new Email($provider['email']), - new String($_POST['delete_reason'])); + new Alphanumeric($_POST['delete_reason'])); } $send_customer = $this->settings_model->get_setting('customer_notifications'); @@ -418,7 +419,7 @@ class Backend_api extends CI_Controller { if ((bool)$send_customer === TRUE) { $email->sendDeleteAppointment($appointment, $provider, $service, $customer, $company_settings, new Email($customer['email']), - new String($_POST['delete_reason'])); + new Alphanumeric($_POST['delete_reason'])); } } catch(Exception $exc) { $warnings[] = exceptionToJavaScript($exc); diff --git a/src/application/controllers/User.php b/src/application/controllers/User.php index d109e66a..263e7160 100644 --- a/src/application/controllers/User.php +++ b/src/application/controllers/User.php @@ -11,7 +11,7 @@ * @since v1.0.0 * ---------------------------------------------------------------------------- */ -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; use \EA\Engine\Types\Email; /** @@ -159,7 +159,7 @@ class User extends CI_Controller { 'company_email' => $this->settings_model->get_setting('company_email') ); - $email->sendPassword(new NonEmptyString($new_password), new Email($_POST['email']), $company_settings); + $email->sendPassword(new NonEmptyAlphanumeric($new_password), new Email($_POST['email']), $company_settings); } echo ($new_password != FALSE) ? json_encode(AJAX_SUCCESS) : json_encode(AJAX_FAILURE); diff --git a/src/application/controllers/api/v1/API_V1_Controller.php b/src/application/controllers/api/v1/API_V1_Controller.php index d166094c..c638a882 100644 --- a/src/application/controllers/api/v1/API_V1_Controller.php +++ b/src/application/controllers/api/v1/API_V1_Controller.php @@ -11,7 +11,7 @@ * @since v1.2.0 * ---------------------------------------------------------------------------- */ -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * API V1 Controller @@ -41,8 +41,8 @@ class API_V1_Controller extends CI_Controller { parent::__construct(); try { - $username = new NonEmptyString($_SERVER['PHP_AUTH_USER']); - $password = new NonEmptyString($_SERVER['PHP_AUTH_PW']); + $username = new NonEmptyAlphanumeric($_SERVER['PHP_AUTH_USER']); + $password = new NonEmptyAlphanumeric($_SERVER['PHP_AUTH_PW']); $authorization = new \EA\Engine\Api\V1\Authorization($this); $authorization->basic($username, $password); } catch(\Exception $exception) { diff --git a/src/application/controllers/api/v1/Admins.php b/src/application/controllers/api/v1/Admins.php index f8145dbe..95eb971f 100644 --- a/src/application/controllers/api/v1/Admins.php +++ b/src/application/controllers/api/v1/Admins.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Admins Controller @@ -88,7 +88,7 @@ class Admins extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->admins_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch (\Exception $exception) { $this->_handleException($exception); diff --git a/src/application/controllers/api/v1/Appointments.php b/src/application/controllers/api/v1/Appointments.php index 1f0f2faf..f5f1ad3c 100644 --- a/src/application/controllers/api/v1/Appointments.php +++ b/src/application/controllers/api/v1/Appointments.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Appointments Controller @@ -88,7 +88,7 @@ class Appointments extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->appointments_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch(\Exception $exception) { exit($this->_handleException($exception)); diff --git a/src/application/controllers/api/v1/Availabilities.php b/src/application/controllers/api/v1/Availabilities.php index 03f2b91b..068e2ee3 100644 --- a/src/application/controllers/api/v1/Availabilities.php +++ b/src/application/controllers/api/v1/Availabilities.php @@ -16,7 +16,7 @@ require_once __DIR__ . '/../../Appointments.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\UnsignedInt; +use \EA\Engine\Types\UnsignedInteger; /** * Availabilities Controller @@ -44,8 +44,8 @@ class Availabilities extends API_V1_Controller { */ public function get() { try { - $providerId = new UnsignedInt($this->input->get('providerId')); - $serviceId = new UnsignedInt($this->input->get('serviceId')); + $providerId = new UnsignedInteger($this->input->get('providerId')); + $serviceId = new UnsignedInteger($this->input->get('serviceId')); if ($this->input->get('date')) { $date = new DateTime($this->input->get('date')); diff --git a/src/application/controllers/api/v1/Categories.php b/src/application/controllers/api/v1/Categories.php index 1b2e7241..9c321008 100644 --- a/src/application/controllers/api/v1/Categories.php +++ b/src/application/controllers/api/v1/Categories.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Categories Controller @@ -88,7 +88,7 @@ class Categories extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->services_model->get_all_categories('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch (\Exception $exception) { $this->_handleException($exception); diff --git a/src/application/controllers/api/v1/Customers.php b/src/application/controllers/api/v1/Customers.php index 5cc63da1..ddbfeee8 100644 --- a/src/application/controllers/api/v1/Customers.php +++ b/src/application/controllers/api/v1/Customers.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Customers Controller @@ -88,7 +88,7 @@ class Customers extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->customers_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch (\Exception $exception) { $this->_handleException($exception); diff --git a/src/application/controllers/api/v1/Providers.php b/src/application/controllers/api/v1/Providers.php index dd2eca88..8249cd65 100644 --- a/src/application/controllers/api/v1/Providers.php +++ b/src/application/controllers/api/v1/Providers.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Providers Controller @@ -88,7 +88,7 @@ class Providers extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->providers_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch (\Exception $exception) { $this->_handleException($exception); diff --git a/src/application/controllers/api/v1/Secretaries.php b/src/application/controllers/api/v1/Secretaries.php index 3820b2f3..3ca8d84f 100644 --- a/src/application/controllers/api/v1/Secretaries.php +++ b/src/application/controllers/api/v1/Secretaries.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Secretaries Controller @@ -88,7 +88,7 @@ class Secretaries extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->secretaries_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch (\Exception $exception) { $this->_handleException($exception); diff --git a/src/application/controllers/api/v1/Services.php b/src/application/controllers/api/v1/Services.php index b2e0397f..2068157f 100644 --- a/src/application/controllers/api/v1/Services.php +++ b/src/application/controllers/api/v1/Services.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Services Controller @@ -88,7 +88,7 @@ class Services extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->services_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch (\Exception $exception) { $this->_handleException($exception); diff --git a/src/application/controllers/api/v1/Settings.php b/src/application/controllers/api/v1/Settings.php index b16af029..9c4a4fa8 100644 --- a/src/application/controllers/api/v1/Settings.php +++ b/src/application/controllers/api/v1/Settings.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Settings Controller diff --git a/src/application/controllers/api/v1/Unavailabilities.php b/src/application/controllers/api/v1/Unavailabilities.php index d13b7857..2e4bdaf1 100644 --- a/src/application/controllers/api/v1/Unavailabilities.php +++ b/src/application/controllers/api/v1/Unavailabilities.php @@ -15,7 +15,7 @@ require_once __DIR__ . '/API_V1_Controller.php'; use \EA\Engine\Api\V1\Response; use \EA\Engine\Api\V1\Request; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * Unavailabilities Controller @@ -88,7 +88,7 @@ class Unavailabilities extends API_V1_Controller { // Fetch the new object from the database and return it to the client. $batch = $this->appointments_model->get_batch('id = ' . $id); $response = new Response($batch); - $status = new NonEmptyString('201 Created'); + $status = new NonEmptyAlphanumeric('201 Created'); $response->encode($this->parser)->singleEntry(true)->output($status); } catch(\Exception $exception) { exit($this->_handleException($exception)); diff --git a/src/engine/Api/V1/Authorization.php b/src/engine/Api/V1/Authorization.php index 3fdc6c59..42961e84 100644 --- a/src/engine/Api/V1/Authorization.php +++ b/src/engine/Api/V1/Authorization.php @@ -13,7 +13,7 @@ namespace EA\Engine\Api\V1; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; /** * API v1 Authorization Class @@ -40,12 +40,12 @@ class Authorization { /** * Perform Basic Authentication * - * @param NonEmptyString $username Admin Username - * @param NonEmptyString $password Admin Password + * @param NonEmptyAlphanumeric $username Admin Username + * @param NonEmptyAlphanumeric $password Admin Password * * @throws \EA\Engine\Api\V1\Exception Throws 401-Unauthorized exception if the authentication fails. */ - public function basic(NonEmptyString $username, NonEmptyString $password) { + public function basic(NonEmptyAlphanumeric $username, NonEmptyAlphanumeric $password) { $this->framework->load->model('user_model'); if (!$this->framework->user_model->check_login($username->get(), $password->get())) { diff --git a/src/engine/Api/V1/Response.php b/src/engine/Api/V1/Response.php index 73e848af..9c7e04d8 100644 --- a/src/engine/Api/V1/Response.php +++ b/src/engine/Api/V1/Response.php @@ -13,7 +13,7 @@ namespace EA\Engine\Api\V1; -use EA\Engine\Types\NonEmptyString; +use EA\Engine\Types\NonEmptyAlphanumeric; /** * API v1 Response @@ -124,12 +124,12 @@ class Response { /** * Output the response as a JSON with the provided status header. * - * @param \EA\Engine\Types\NonEmptyString $status Optional (null), if provided it must contain the status + * @param \EA\Engine\Types\NonEmptyAlphanumeric $status Optional (null), if provided it must contain the status * header value. Default string: '200 OK'. * * @return \EA\Engine\Api\V1\Response */ - public function output(NonEmptyString $status = null) { + public function output(NonEmptyAlphanumeric $status = null) { $header = $status ? $status->get() : '200 OK'; header('HTTP/1.0 ' . $header); diff --git a/src/engine/Notifications/Email.php b/src/engine/Notifications/Email.php index 90b0c011..c4b98581 100644 --- a/src/engine/Notifications/Email.php +++ b/src/engine/Notifications/Email.php @@ -13,8 +13,8 @@ namespace EA\Engine\Notifications; -use \EA\Engine\Types\String; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\Alphanumeric; +use \EA\Engine\Types\NonEmptyAlphanumeric; use \EA\Engine\Types\Url; use \EA\Engine\Types\Email as EmailAddress; @@ -98,15 +98,15 @@ class Email { * @param array $customer Contains the customer data. * @param array $company Contains settings of the company. By the time the * "company_name", "company_link" and "company_email" values are required in the array. - * @param \EA\Engine\Types\String $title The email title may vary depending the receiver. - * @param \EA\Engine\Types\String $message The email message may vary depending the receiver. + * @param \EA\Engine\Types\Alphanumeric $title The email title may vary depending the receiver. + * @param \EA\Engine\Types\Alphanumeric $message The email message may vary depending the receiver. * @param \EA\Engine\Types\Url $appointmentLink This link is going to enable the receiver to make changes * to the appointment record. * @param \EA\Engine\Types\Email $recipientEmail The recipient email address. */ public function sendAppointmentDetails(array $appointment, array $provider, array $service, - array $customer, array $company, String $title, String $message, Url $appointmentLink, - EmailAddress $recipientEmail) { + array $customer, array $company, Alphanumeric $title, Alphanumeric $message, Url $appointmentLink, + EmailAddress $recipientEmail) { // Prepare template replace array. $replaceArray = array( @@ -172,8 +172,8 @@ class Email { * @param \EA\Engine\Tyeps\String $reason The reason why the appointment is deleted. */ public function sendDeleteAppointment(array $appointment, array $provider, - array $service, array $customer, array $company, EmailAddress $recipientEmail, - String $reason) { + array $service, array $customer, array $company, EmailAddress $recipientEmail, + Alphanumeric $reason) { // Prepare email template data. $replaceArray = array( '$email_title' => $this->framework->lang->line('appointment_cancelled_title'), @@ -223,11 +223,11 @@ class Email { /** * This method sends an email with the new password of a user. * - * @param \EA\Engine\Types\NonEmptyString $password Contains the new password. + * @param \EA\Engine\Types\NonEmptyAlphanumeric $password Contains the new password. * @param \EA\Engine\Types\Email $email The receiver's email address. * @param array $company The company settings to be included in the email. */ - public function sendPassword(NonEmptyString $password, EmailAddress $recipientEmail, array $company) { + public function sendPassword(NonEmptyAlphanumeric $password, EmailAddress $recipientEmail, array $company) { $replaceArray = array( '$email_title' => $this->framework->lang->line('new_account_password'), '$email_message' => $this->framework->lang->line('new_password_is'), diff --git a/src/engine/Types/String.php b/src/engine/Types/Alphanumeric.php similarity index 94% rename from src/engine/Types/String.php rename to src/engine/Types/Alphanumeric.php index 2f86e930..43c46246 100644 --- a/src/engine/Types/String.php +++ b/src/engine/Types/Alphanumeric.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class String extends Type { +class Alphanumeric extends Type { protected function _validate($value) { return is_string($value); } diff --git a/src/engine/Types/Bool.php b/src/engine/Types/Boolean.php similarity index 95% rename from src/engine/Types/Bool.php rename to src/engine/Types/Boolean.php index d2d255e8..490c494a 100644 --- a/src/engine/Types/Bool.php +++ b/src/engine/Types/Boolean.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class Bool extends Type { +class Boolean extends Type { protected function _validate($value) { return is_bool($value); } diff --git a/src/engine/Types/Float.php b/src/engine/Types/Decimal.php similarity index 95% rename from src/engine/Types/Float.php rename to src/engine/Types/Decimal.php index e26c695b..4c37ee44 100644 --- a/src/engine/Types/Float.php +++ b/src/engine/Types/Decimal.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class Float extends Type { +class Decimal extends Type { protected function _validate($value) { return is_float($value); } diff --git a/src/engine/Types/Email.php b/src/engine/Types/Email.php index 5d338596..e40c73b1 100644 --- a/src/engine/Types/Email.php +++ b/src/engine/Types/Email.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class Email extends NonEmptyString { +class Email extends NonEmptyAlphanumeric { protected function _validate($value) { return parent::_validate($value) && filter_var($value, FILTER_VALIDATE_EMAIL); } diff --git a/src/engine/Types/Int.php b/src/engine/Types/Integer.php similarity index 95% rename from src/engine/Types/Int.php rename to src/engine/Types/Integer.php index affa0d64..5a68dd1e 100644 --- a/src/engine/Types/Int.php +++ b/src/engine/Types/Integer.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class Int extends Type { +class Integer extends Type { protected function _validate($value) { return is_numeric($value) && !is_float($value); } diff --git a/src/engine/Types/NonEmptyString.php b/src/engine/Types/NonEmptyAlphanumeric.php similarity index 92% rename from src/engine/Types/NonEmptyString.php rename to src/engine/Types/NonEmptyAlphanumeric.php index 516e3934..f3f1c3d7 100644 --- a/src/engine/Types/NonEmptyString.php +++ b/src/engine/Types/NonEmptyAlphanumeric.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class NonEmptyString extends String { +class NonEmptyAlphanumeric extends Alphanumeric { protected function _validate($value) { return parent::_validate($value) && $value !== ''; } diff --git a/src/engine/Types/UnsignedInt.php b/src/engine/Types/UnsignedInteger.php similarity index 94% rename from src/engine/Types/UnsignedInt.php rename to src/engine/Types/UnsignedInteger.php index 3af061b8..59f4dd99 100644 --- a/src/engine/Types/UnsignedInt.php +++ b/src/engine/Types/UnsignedInteger.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class UnsignedInt extends Int { +class UnsignedInteger extends Integer { protected function _validate($value) { return parent::_validate($value) && $value > -1; } diff --git a/src/engine/Types/Url.php b/src/engine/Types/Url.php index 367d055d..4cdaa910 100644 --- a/src/engine/Types/Url.php +++ b/src/engine/Types/Url.php @@ -13,7 +13,7 @@ namespace EA\Engine\Types; -class Url extends NonEmptyString { +class Url extends NonEmptyAlphanumeric { protected function _validate($value) { return parent::_validate($value) && filter_var($value, FILTER_VALIDATE_URL); } diff --git a/test/php/engine/Api/V1/AuthorizationTest.php b/test/php/engine/Api/V1/AuthorizationTest.php index 85ce9f90..7cc8085a 100644 --- a/test/php/engine/Api/V1/AuthorizationTest.php +++ b/test/php/engine/Api/V1/AuthorizationTest.php @@ -13,7 +13,7 @@ namespace EA\Engine\Api\V1; -use \EA\Engine\Types\NonEmptyString; +use \EA\Engine\Types\NonEmptyAlphanumeric; class AuthorizationTest extends \PHPUnit_Framework_TestCase { public function testBasicMethodPerformsBasicAuthentication() { diff --git a/test/php/engine/Types/StringTest.php b/test/php/engine/Types/AlphanumericTest.php similarity index 84% rename from test/php/engine/Types/StringTest.php rename to test/php/engine/Types/AlphanumericTest.php index adea4ba3..25df5548 100644 --- a/test/php/engine/Types/StringTest.php +++ b/test/php/engine/Types/AlphanumericTest.php @@ -13,14 +13,14 @@ namespace EA\Engine\Types; -class StringTest extends \PHPUnit_Framework_TestCase { +class AlphanumericTest extends \PHPUnit_Framework_TestCase { public function testStringType() { - $type = new String('Hello!'); + $type = new Alphanumeric('Hello!'); $this->assertEquals('Hello!', $type->get()); } public function testStringTypeThrowsExceptionWithInvalidValue() { $this->setExpectedException('\InvalidArgumentException'); - new String(null); + new Alphanumeric(null); } } diff --git a/test/php/engine/Types/BoolTest.php b/test/php/engine/Types/BooleanTest.php similarity index 86% rename from test/php/engine/Types/BoolTest.php rename to test/php/engine/Types/BooleanTest.php index da790590..501c0d9b 100644 --- a/test/php/engine/Types/BoolTest.php +++ b/test/php/engine/Types/BooleanTest.php @@ -13,14 +13,14 @@ namespace EA\Engine\Types; -class BoolTest extends \PHPUnit_Framework_TestCase { +class BooleanTest extends \PHPUnit_Framework_TestCase { public function testBoolType() { - $type = new Bool(true); + $type = new Boolean(true); $this->assertEquals(true, $type->get()); } public function testBoolTypeThrowsExceptionWithInvalidValue() { $this->setExpectedException('\InvalidArgumentException'); - new Bool(null); + new Boolean(null); } } diff --git a/test/php/engine/Types/FloatTest.php b/test/php/engine/Types/DecimalTest.php similarity index 86% rename from test/php/engine/Types/FloatTest.php rename to test/php/engine/Types/DecimalTest.php index 234b27ea..41e99c55 100644 --- a/test/php/engine/Types/FloatTest.php +++ b/test/php/engine/Types/DecimalTest.php @@ -13,14 +13,14 @@ namespace EA\Engine\Types; -class FloatTest extends \PHPUnit_Framework_TestCase { +class DecimalTest extends \PHPUnit_Framework_TestCase { public function testFloatType() { - $type = new Float(100.00); + $type = new Decimal(100.00); $this->assertEquals(100.00, $type->get()); } public function testFloatTypeThrowsExceptionWithInvalidValue() { $this->setExpectedException('\InvalidArgumentException'); - new Float(null); + new Decimal(null); } } diff --git a/test/php/engine/Types/IntTest.php b/test/php/engine/Types/IntegerTest.php similarity index 85% rename from test/php/engine/Types/IntTest.php rename to test/php/engine/Types/IntegerTest.php index eaebd519..70bbca0f 100644 --- a/test/php/engine/Types/IntTest.php +++ b/test/php/engine/Types/IntegerTest.php @@ -13,19 +13,19 @@ namespace EA\Engine\Types; -class IntTest extends \PHPUnit_Framework_TestCase { +class IntegerTest extends \PHPUnit_Framework_TestCase { public function testIntType() { - $type = new Int(1); + $type = new Integer(1); $this->assertEquals(1, $type->get()); } public function testIntTypeThrowsExceptionWithFloat() { $this->setExpectedException('\InvalidArgumentException'); - new Int(100.00); + new Integer(100.00); } public function testIntTypeThrowsExceptionWithWithString() { $this->setExpectedException('\InvalidArgumentException'); - new Int('invalid'); + new Integer('invalid'); } } diff --git a/test/php/engine/Types/NonEmptyStringTest.php b/test/php/engine/Types/NonEmptyAlphanumericTest.php similarity index 82% rename from test/php/engine/Types/NonEmptyStringTest.php rename to test/php/engine/Types/NonEmptyAlphanumericTest.php index 95f3f633..92939825 100644 --- a/test/php/engine/Types/NonEmptyStringTest.php +++ b/test/php/engine/Types/NonEmptyAlphanumericTest.php @@ -13,19 +13,19 @@ namespace EA\Engine\Types; -class NonEmptyStringTest extends \PHPUnit_Framework_TestCase { +class NonEmptyAlphanumericTest extends \PHPUnit_Framework_TestCase { public function testNonEmptyStringType() { - $type = new NonEmptyString('Hello!'); + $type = new NonEmptyAlphanumeric('Hello!'); $this->assertEquals('Hello!', $type->get()); } public function testNonEmptyStringTypeThrowsExceptionWithEmptyString() { $this->setExpectedException('\InvalidArgumentException'); - new NonEmptyString(''); + new NonEmptyAlphanumeric(''); } public function testNonEmptyStringTypeThrowsExceptionWithInvalidValue() { $this->setExpectedException('\InvalidArgumentException'); - new NonEmptyString(null); + new NonEmptyAlphanumeric(null); } } diff --git a/test/php/engine/Types/UnsignedIntTest.php b/test/php/engine/Types/UnsignedIntegerTest.php similarity index 83% rename from test/php/engine/Types/UnsignedIntTest.php rename to test/php/engine/Types/UnsignedIntegerTest.php index ebadd997..6815a3b1 100644 --- a/test/php/engine/Types/UnsignedIntTest.php +++ b/test/php/engine/Types/UnsignedIntegerTest.php @@ -13,19 +13,19 @@ namespace EA\Engine\Types; -class UnsignedIntTest extends \PHPUnit_Framework_TestCase { +class UnsignedIntegerTest extends \PHPUnit_Framework_TestCase { public function testUnsignedIntType() { - $type = new UnsignedInt(1); + $type = new UnsignedInteger(1); $this->assertEquals(1, $type->get()); } public function testUnsignedIntTypeThrowsExceptionWithNegative() { $this->setExpectedException('\InvalidArgumentException'); - new UnsignedInt(-1); + new UnsignedInteger(-1); } public function testUnsignedIntTypeThrowsExceptionWithWithString() { $this->setExpectedException('\InvalidArgumentException'); - new UnsignedInt('invalid'); + new UnsignedInteger('invalid'); } }