Compare commits
10 Commits
genericAss
...
qualityCha
| Author | SHA1 | Date | |
|---|---|---|---|
| 231e7fe2e6 | |||
| f820a22a4f | |||
| 0cdfd21fa2 | |||
| fee3db486f | |||
| 87181696e1 | |||
| 8b22c0db9c | |||
| 18ee0ad333 | |||
| 4928481f72 | |||
|
|
2d11218076 | ||
| 59a4d6e4a5 |
@@ -1 +1,2 @@
|
|||||||
Options -Indexes
|
Options -Indexes
|
||||||
|
Deny from all
|
||||||
|
|||||||
@@ -1,10 +1,29 @@
|
|||||||
|
# Stage 1 - the build process
|
||||||
|
FROM composer:1.7.1 as build-deps
|
||||||
|
ENV COMPOSER_ALLOW_SUPERUSER 1
|
||||||
|
|
||||||
|
WORKDIR /root
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
RUN composer install
|
||||||
|
RUN composer test
|
||||||
|
|
||||||
|
# Stage 2 - the production environment
|
||||||
FROM ubuntu:16.04
|
FROM ubuntu:16.04
|
||||||
|
|
||||||
# Updating
|
|
||||||
RUN apt-get -y update && apt-get -y upgrade
|
RUN apt-get -y update && apt-get -y upgrade
|
||||||
|
|
||||||
# Installing php, apache and supplementary software
|
RUN apt-get -y install apache2 \
|
||||||
RUN apt-get -y install apache2 php7.0 libapache2-mod-php7.0 php7.0-cli php7.0-common php7.0-mbstring php7.0-gd php7.0-intl php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-zip curl git unzip composer
|
php7.0 \
|
||||||
|
libapache2-mod-php7.0 \
|
||||||
|
php7.0-cli \
|
||||||
|
php7.0-common \
|
||||||
|
php7.0-mbstring \
|
||||||
|
php7.0-gd \
|
||||||
|
php7.0-intl \
|
||||||
|
php7.0-xml \
|
||||||
|
php7.0-mysql \
|
||||||
|
php7.0-mcrypt
|
||||||
|
|
||||||
# Enable apache mods
|
# Enable apache mods
|
||||||
RUN a2enmod php7.0
|
RUN a2enmod php7.0
|
||||||
@@ -20,24 +39,14 @@ ENV APACHE_RUN_GROUP www-data
|
|||||||
ENV APACHE_LOG_DIR /var/log/apache2
|
ENV APACHE_LOG_DIR /var/log/apache2
|
||||||
ENV APACHE_LOCK_DIR /var/lock/apache2
|
ENV APACHE_LOCK_DIR /var/lock/apache2
|
||||||
|
|
||||||
# Expose apache
|
|
||||||
EXPOSE 80
|
|
||||||
|
|
||||||
# Copy this repo into place.
|
|
||||||
ADD . /var/www/site
|
|
||||||
WORKDIR /var/www/site
|
WORKDIR /var/www/site
|
||||||
|
COPY --from=build-deps /root .
|
||||||
|
|
||||||
# Testing permisions
|
RUN touch logs/app.log
|
||||||
RUN chmod 777 -R .
|
RUN chmod 777 logs/app.log
|
||||||
|
|
||||||
# Installing dependencies
|
# Update the default apache site
|
||||||
RUN composer install
|
ADD docker/apache-config.conf /etc/apache2/sites-enabled/000-default.conf
|
||||||
|
|
||||||
# Unit tests
|
# By default start up apache in the foreground
|
||||||
RUN composer test
|
|
||||||
|
|
||||||
# Update the default apache site with the config we created.
|
|
||||||
ADD apache-config.conf /etc/apache2/sites-enabled/000-default.conf
|
|
||||||
|
|
||||||
# By default start up apache in the foreground, override with /bin/bash for interative
|
|
||||||
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
CMD /usr/sbin/apache2ctl -D FOREGROUND
|
||||||
|
|||||||
0
api-payroll/logs/app.log
Executable file
0
api-payroll/logs/app.log
Executable file
@@ -1,3 +1,5 @@
|
|||||||
|
allow from all
|
||||||
|
|
||||||
<IfModule mod_rewrite.c>
|
<IfModule mod_rewrite.c>
|
||||||
RewriteEngine On
|
RewriteEngine On
|
||||||
|
|
||||||
|
|||||||
@@ -56,11 +56,11 @@ class EmployeeApplication{
|
|||||||
* @return integer
|
* @return integer
|
||||||
*/
|
*/
|
||||||
function saveNewPerson($firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
function saveNewPerson($firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
||||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
$this->asserts->firstName($firstName);
|
||||||
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
$this->asserts->middleName($middleName);
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->birthDate($birthDate);
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->email($email);
|
||||||
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
$this->asserts->phone($phone);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("INSERT INTO persons (firstName, middleName, lastName, birthDate, email, phone)
|
$stmt = $this->pdo->prepare("INSERT INTO persons (firstName, middleName, lastName, birthDate, email, phone)
|
||||||
@@ -89,10 +89,6 @@ class EmployeeApplication{
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function savePersonAsEmployee($idEmployeeType, $idPerson, $code, $contractType){
|
function savePersonAsEmployee($idEmployeeType, $idPerson, $code, $contractType){
|
||||||
$this->asserts->higherThanZero($idEmployeeType, "idEmployeeType must be higher than 0");
|
|
||||||
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
|
||||||
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("INSERT INTO employees (idEmployeeType, idPerson, code, contractType)
|
$stmt = $this->pdo->prepare("INSERT INTO employees (idEmployeeType, idPerson, code, contractType)
|
||||||
VALUES (:idEmployeeType, :idPerson, :code, :contractType)");
|
VALUES (:idEmployeeType, :idPerson, :code, :contractType)");
|
||||||
@@ -119,29 +115,21 @@ class EmployeeApplication{
|
|||||||
function saveNewEmployee($requestData){
|
function saveNewEmployee($requestData){
|
||||||
// Getting and validating the data
|
// Getting and validating the data
|
||||||
$firstName = $requestData['firstName'];
|
$firstName = $requestData['firstName'];
|
||||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
$this->asserts->firstName($firstName);
|
||||||
$this->asserts->isString($firstName, "The first name must be a string.");
|
|
||||||
$this->asserts->betweenLength($firstName, 1, 50, "The first name must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
$middleName = $requestData['middleName'];
|
$middleName = $requestData['middleName'];
|
||||||
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
$this->asserts->middleName($middleName);
|
||||||
$this->asserts->isString($middleName, "The middle name must be a string.");
|
|
||||||
$this->asserts->betweenLength($middleName, 1, 50, "The middle name must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
$lastName = isset($requestData['lastName'])
|
$lastName = isset($requestData['lastName']) ? $requestData['lastName'] : null;
|
||||||
? $requestData['lastName']
|
|
||||||
: null;
|
|
||||||
|
|
||||||
$birthDate = $requestData['birthDate'];
|
$birthDate = $requestData['birthDate'];
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->birthDate($birthDate);
|
||||||
|
|
||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->email($email);
|
||||||
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
|
||||||
|
|
||||||
$phone = $requestData['phone'];
|
$phone = $requestData['phone'];
|
||||||
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
$this->asserts->phone($phone);
|
||||||
$this->asserts->betweenLength($phone, 10, 10, "The phone number must be 10 digits without special characters.");
|
|
||||||
|
|
||||||
$idEmployeeType = $requestData{'idEmployeeType'};
|
$idEmployeeType = $requestData{'idEmployeeType'};
|
||||||
$contractType = $requestData{'contractType'};
|
$contractType = $requestData{'contractType'};
|
||||||
@@ -181,8 +169,6 @@ class EmployeeApplication{
|
|||||||
* @return Integer
|
* @return Integer
|
||||||
*/
|
*/
|
||||||
function getIdPersonByIdEmployee($idEmployee){
|
function getIdPersonByIdEmployee($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
|
||||||
|
|
||||||
$stmt = $this->pdo->prepare("SELECT
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
COALESCE((SELECT
|
COALESCE((SELECT
|
||||||
idPerson
|
idPerson
|
||||||
@@ -203,12 +189,10 @@ class EmployeeApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $code string
|
* @param $code
|
||||||
* @return integer
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function getIdEmployeeTypeByCode($code){
|
function getIdEmployeeTypeByCode($code){
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
|
||||||
|
|
||||||
$stmt = $this->pdo->prepare("SELECT COALESCE((SELECT
|
$stmt = $this->pdo->prepare("SELECT COALESCE((SELECT
|
||||||
et.id
|
et.id
|
||||||
FROM
|
FROM
|
||||||
@@ -235,8 +219,6 @@ class EmployeeApplication{
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getEmployeeDataById($idEmployee){
|
function getEmployeeDataById($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
|
||||||
|
|
||||||
$stmt = $this->pdo->prepare("SELECT
|
$stmt = $this->pdo->prepare("SELECT
|
||||||
p.id AS idPerson,
|
p.id AS idPerson,
|
||||||
p.firstName,
|
p.firstName,
|
||||||
@@ -271,8 +253,6 @@ class EmployeeApplication{
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function proxyGetEmployeeDataById($idEmployee){
|
function proxyGetEmployeeDataById($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
|
||||||
|
|
||||||
$employeeData = $this->getEmployeeDataById($idEmployee);
|
$employeeData = $this->getEmployeeDataById($idEmployee);
|
||||||
|
|
||||||
$response = array(
|
$response = array(
|
||||||
@@ -299,8 +279,6 @@ class EmployeeApplication{
|
|||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
function getEmployeeDataByCode($code){
|
function getEmployeeDataByCode($code){
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
|
||||||
|
|
||||||
$idEmployee = $this->getIdEmployeeTypeByCode($code);
|
$idEmployee = $this->getIdEmployeeTypeByCode($code);
|
||||||
|
|
||||||
return $this->proxyGetEmployeeDataById($idEmployee);
|
return $this->proxyGetEmployeeDataById($idEmployee);
|
||||||
@@ -316,13 +294,6 @@ class EmployeeApplication{
|
|||||||
* @param $phone string
|
* @param $phone string
|
||||||
*/
|
*/
|
||||||
function updatePerson($idPerson, $firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
function updatePerson($idPerson, $firstName, $middleName, $lastName, $birthDate, $email, $phone){
|
||||||
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
|
||||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
|
||||||
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
|
||||||
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("UPDATE persons
|
$stmt = $this->pdo->prepare("UPDATE persons
|
||||||
SET
|
SET
|
||||||
@@ -352,11 +323,6 @@ class EmployeeApplication{
|
|||||||
* @param $contractType string
|
* @param $contractType string
|
||||||
*/
|
*/
|
||||||
function updateEmployee($idEmployee, $code, $idEmployeeType, $contractType){
|
function updateEmployee($idEmployee, $code, $idEmployeeType, $contractType){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
|
||||||
$this->asserts->higherThanZero($idEmployeeType, "idEmployeeType must be higher than 0");
|
|
||||||
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("UPDATE employees
|
$stmt = $this->pdo->prepare("UPDATE employees
|
||||||
SET
|
SET
|
||||||
@@ -383,42 +349,28 @@ class EmployeeApplication{
|
|||||||
function updateEmployeeData($requestData){
|
function updateEmployeeData($requestData){
|
||||||
// Getting and validating the data
|
// Getting and validating the data
|
||||||
$idEmployee = $requestData['idEmployee'];
|
$idEmployee = $requestData['idEmployee'];
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
|
||||||
|
|
||||||
$idPerson = $this->getIdPersonByIdEmployee($idEmployee);
|
$idPerson = $this->getIdPersonByIdEmployee($idEmployee);
|
||||||
$this->asserts->higherThanZero($idPerson, "idPerson must be higher than 0");
|
|
||||||
|
|
||||||
$code = $requestData['code'];
|
$code = $requestData['code'];
|
||||||
$this->asserts->isNotEmpty($code, "The code can't be empty.");
|
|
||||||
|
|
||||||
$firstName = $requestData['firstName'];
|
$firstName = $requestData['firstName'];
|
||||||
$this->asserts->isNotEmpty($firstName, "The first name can't be empty.");
|
$this->asserts->firstName($firstName);
|
||||||
$this->asserts->isString($firstName, "The first name must be a string.");
|
|
||||||
$this->asserts->betweenLength($firstName, 1, 50, "The first name must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
$middleName = $requestData['middleName'];
|
$middleName = $requestData['middleName'];
|
||||||
$this->asserts->isNotEmpty($middleName, "The middle name can't be empty.");
|
$this->asserts->middleName($middleName);
|
||||||
$this->asserts->isString($middleName, "The middle name must be a string.");
|
|
||||||
$this->asserts->betweenLength($middleName, 1, 50, "The middle name must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
$lastName = isset($requestData['lastName']) ? $requestData['lastName'] : null;
|
$lastName = isset($requestData['lastName']) ? $requestData['lastName'] : null;
|
||||||
|
|
||||||
$birthDate = $requestData['birthDate'];
|
$birthDate = $requestData['birthDate'];
|
||||||
$this->asserts->isNotEmpty($birthDate, "The birth date can't be empty.");
|
$this->asserts->birthDate($birthDate);
|
||||||
|
|
||||||
$email = $requestData['email'];
|
$email = $requestData['email'];
|
||||||
$this->asserts->isNotEmpty($email, "The email can't be empty.");
|
$this->asserts->email($email);
|
||||||
$this->asserts->betweenLength($email, 1, 100, "The middle name must have a length between 1 and 100 characters.");
|
|
||||||
|
|
||||||
$phone = $requestData['phone'];
|
$phone = $requestData['phone'];
|
||||||
$this->asserts->isNotEmpty($phone, "The phone number can't be empty.");
|
$this->asserts->phone($phone);
|
||||||
$this->asserts->betweenLength($phone, 10, 10, "The phone number must be 10 digits without special characters.");
|
|
||||||
|
|
||||||
$idEmployeeType = $requestData{'idEmployeeType'};
|
$idEmployeeType = $requestData{'idEmployeeType'};
|
||||||
$this->asserts->higherThanZero($idEmployeeType, "idEmployeeType must be higher than 0");
|
|
||||||
|
|
||||||
$contractType = $requestData{'contractType'};
|
$contractType = $requestData{'contractType'};
|
||||||
$this->asserts->isNotEmpty($contractType, "The contract type can't be empty.");
|
|
||||||
|
|
||||||
// Encrypting the sensitive data
|
// Encrypting the sensitive data
|
||||||
$securedFirstName = $this->cryptographyService->encryptString($firstName);
|
$securedFirstName = $this->cryptographyService->encryptString($firstName);
|
||||||
@@ -452,8 +404,6 @@ class EmployeeApplication{
|
|||||||
}
|
}
|
||||||
|
|
||||||
function disableEmployeeRecord($idEmployee){
|
function disableEmployeeRecord($idEmployee){
|
||||||
$this->asserts->higherThanZero($idEmployee, "idEmployee must be higher than 0");
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$stmt = $this->pdo->prepare("UPDATE employees
|
$stmt = $this->pdo->prepare("UPDATE employees
|
||||||
SET
|
SET
|
||||||
@@ -497,9 +447,6 @@ class EmployeeApplication{
|
|||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return array
|
|
||||||
*/
|
|
||||||
function listAllActiveEmployees(){
|
function listAllActiveEmployees(){
|
||||||
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
$ids = $this->getIdEmployeeFromAllActiveEmployees();
|
||||||
|
|
||||||
|
|||||||
@@ -43,9 +43,7 @@ class SessionApplication{
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
function getPassword($userName){
|
function getPassword($userName){
|
||||||
$this->asserts->isNotEmpty($userName, "The username can't be empty");
|
$this->asserts->userName($userName);
|
||||||
$this->asserts->isString($userName, "The username must be a string.");
|
|
||||||
$this->asserts->betweenLength($userName, 1, 50, "The username must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
$stmt = $this->pdo->prepare("SELECT password FROM users WHERE name = :userName");
|
$stmt = $this->pdo->prepare("SELECT password FROM users WHERE name = :userName");
|
||||||
$stmt->execute(array(':userName' => $userName));
|
$stmt->execute(array(':userName' => $userName));
|
||||||
@@ -64,12 +62,8 @@ class SessionApplication{
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function newSession($userName, $password){
|
function newSession($userName, $password){
|
||||||
$this->asserts->isNotEmpty($userName, "The username can't be empty");
|
$this->asserts->userName($userName);
|
||||||
$this->asserts->isString($userName, "The username must be a string.");
|
$this->asserts->password($password);
|
||||||
$this->asserts->betweenLength($userName, 1, 50, "The username must have a length between 1 and 50 characters.");
|
|
||||||
$this->asserts->isNotEmpty($password, "The password can't be empty");
|
|
||||||
$this->asserts->isString($password, "The password must be a string.");
|
|
||||||
$this->asserts->betweenLength($password, 1, 50, "The password must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
$storedPassword = $this->getPassword($userName);
|
$storedPassword = $this->getPassword($userName);
|
||||||
|
|
||||||
@@ -99,14 +93,6 @@ class SessionApplication{
|
|||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function login($userName, $password){
|
function login($userName, $password){
|
||||||
$this->asserts->isNotEmpty($userName, "The username can't be empty");
|
|
||||||
$this->asserts->isString($userName, "The username must be a string.");
|
|
||||||
$this->asserts->betweenLength($userName, 1, 50, "The username must have a length between 1 and 50 characters.");
|
|
||||||
$this->asserts->isNotEmpty($password, "The password can't be empty");
|
|
||||||
$this->asserts->isString($password, "The password must be a string.");
|
|
||||||
$this->asserts->betweenLength($password, 1, 50, "The password must have a length between 1 and 50 characters.");
|
|
||||||
|
|
||||||
|
|
||||||
if($this->newSession($userName, $password)){
|
if($this->newSession($userName, $password)){
|
||||||
return array('status' => 'success', 'message' => 'Logged in successfully.');
|
return array('status' => 'success', 'message' => 'Logged in successfully.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,54 +6,78 @@ use Respect\Validation\Validator as v;
|
|||||||
|
|
||||||
class Asserts{
|
class Asserts{
|
||||||
/**
|
/**
|
||||||
* @param $string string
|
* @param $string
|
||||||
* @param $errorMessage string
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function isString($string, $errorMessage){
|
function userName($string){
|
||||||
$validation = v::stringType()->validate($string);
|
$validateFirstName = v::stringType()->notEmpty()->length(1, 50)->validate($string);
|
||||||
|
|
||||||
if(!$validation){
|
if(!$validateFirstName){
|
||||||
throw new Exception($errorMessage);
|
throw new Exception('The user name must be a string between 1 and 50 characters');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $string string
|
* @param $string
|
||||||
* @param $errorMessage string
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function isNotEmpty($string, $errorMessage){
|
function password($string){
|
||||||
$validation = v::notEmpty()->validate($string);
|
$validateFirstName = v::stringType()->notEmpty()->length(1, 50)->validate($string);
|
||||||
|
|
||||||
if(!$validation){
|
if(!$validateFirstName){
|
||||||
throw new Exception($errorMessage);
|
throw new Exception('The password must be a string between 1 and 50 characters');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $string string
|
* @param $string
|
||||||
* @param $min integer
|
|
||||||
* @param $max integer
|
|
||||||
* @param $errorMessage string
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function betweenLength($string, $min, $max, $errorMessage){
|
function firstName($string){
|
||||||
$validation = v::length($min, $max)->validate($string);
|
$validateFirstName = v::stringType()->notEmpty()->length(1, 100)->validate($string);
|
||||||
|
|
||||||
if(!$validation){
|
if(!$validateFirstName){
|
||||||
throw new Exception($errorMessage);
|
throw new Exception('The first name must be a string between 1 and 100 characters');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param $number integer
|
* @param $string
|
||||||
* @param $errorMessage string
|
|
||||||
* @throws Exception
|
* @throws Exception
|
||||||
*/
|
*/
|
||||||
function higherThanZero($number, $errorMessage){
|
function middleName($string){
|
||||||
if($number <= 0){
|
if(!v::stringType()->notEmpty()->length(1, 100)->validate($string)){
|
||||||
throw new Exception($errorMessage);
|
throw new Exception('The middle name must be a string between 1 and 100 characters');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $string
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function birthDate($string){
|
||||||
|
if(!v::date('Y-m-d')->notEmpty()->validate($string)){
|
||||||
|
throw new Exception('The birth date must be in the yyyy-mm-dd format');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $string
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function email($string){
|
||||||
|
if(!v::stringType()->notEmpty()->length(1, 100)->validate($string)){
|
||||||
|
throw new Exception('The email must be a string between 1 and 100 characters');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param $string
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
function phone($string){
|
||||||
|
if(!v::digit()->notEmpty()->length(10, 10)->validate($string)){
|
||||||
|
throw new Exception('The phone must be a numeric value of 10 digits');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8085:80"
|
- "8085:80"
|
||||||
volumes:
|
volumes:
|
||||||
- api-payroll:/var/www/site
|
- ./volumes/apache-logs:/var/log/apache2
|
||||||
depends_on:
|
depends_on:
|
||||||
- mysql
|
- mysql
|
||||||
mysql:
|
mysql:
|
||||||
@@ -18,11 +18,11 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "3307:3307"
|
- "3307:3307"
|
||||||
volumes:
|
volumes:
|
||||||
- my-datavolume:/var/lib/mysql
|
- ./volumes/mysql-data:/var/lib/mysql
|
||||||
environment:
|
environment:
|
||||||
MYSQL_ROOT_PASSWORD: '12345678'
|
MYSQL_ROOT_PASSWORD: '12345678'
|
||||||
MYSQL_USER: 'sloth'
|
MYSQL_USER: 'sloth'
|
||||||
MYSQL_PASS: '12345678'
|
MYSQL_PASS: '12345678'
|
||||||
volumes:
|
volumes:
|
||||||
api-payroll:
|
mysql-data:
|
||||||
my-datavolume:
|
apache-logs:
|
||||||
|
|||||||
2
volumes/.gitignore
vendored
Normal file
2
volumes/.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
mysql-data/
|
||||||
|
apache-logs/
|
||||||
1
volumes/README.md
Normal file
1
volumes/README.md
Normal file
@@ -0,0 +1 @@
|
|||||||
|
# Do not delete this directory, it'll contain the volumes created by the containers
|
||||||
Reference in New Issue
Block a user