Skip to content

Commit

Permalink
Changelog 1.20.0 :
Browse files Browse the repository at this point in the history
- Add new function concatenate in JSON class
- Update comment in some classes
- Update readme
- Update version to 1.20.0
  • Loading branch information
aalfiann committed Oct 24, 2018
1 parent b26f2f5 commit cf30f23
Show file tree
Hide file tree
Showing 9 changed files with 71 additions and 49 deletions.
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
reSlim
=======
[![Coverage](https://img.shields.io/badge/coverage-100%25-brightgreen.svg)](https://github.com/aalfiann/reSlim)
[![reSlim](https://img.shields.io/badge/stable-1.19.0-brightgreen.svg)](https://github.com/aalfiann/reSlim)
[![reSlim](https://img.shields.io/badge/stable-1.20.0-brightgreen.svg)](https://github.com/aalfiann/reSlim)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/aalfiann/reSlim/blob/master/license.md)

reSlim is Lightweight, Fast, Secure, Simple, Scalable, Flexible and Powerful rest api framework.<br>
Expand Down
2 changes: 1 addition & 1 deletion src/app/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
require '../config.php';

// Declare reSlim Version
define('RESLIM_VERSION','1.19.0');
define('RESLIM_VERSION','1.20.0');
// Declare reSlim built-in cache
define('AUTH_CACHE',$config['reslim']['authcache']);
define('SIMPLE_CACHE',$config['reslim']['simplecache']);
Expand Down
78 changes: 50 additions & 28 deletions src/classes/JSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class JSON {
/**
* Convert string to valid UTF8 chars (Faster but not support for ANSII)
*
* @var string is the array string or value
* @param string is the array string or value
*
* @return string
*/
Expand All @@ -43,7 +43,7 @@ private static function convertToUTF8($string){
/**
* Convert string to valid UTF8 chars (slower but support ANSII)
*
* @var string is the array string or value
* @param string is the array string or value
*
* @return string
*/
Expand All @@ -61,11 +61,11 @@ private static function safeConvertToUTF8($string){
/**
* Encode Array string or value to json (faster with no any conversion to utf8)
*
* @var data is the array string or value
* @var withlog if set to true then will append logger data. Default is false.
* @var pretty is to make ouput json nice, clean and readable. Default is false for perfomance speed reason.
* @var options is to set the options of json_encode. Ex: JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_HEX_TAG|JSON_HEX_APOS
* @var depth is to set the recursion depth. Default is 512.
* @param data is the array string or value
* @param withlog if set to true then will append logger data. Default is false.
* @param pretty is to make ouput json nice, clean and readable. Default is false for perfomance speed reason.
* @param options is to set the options of json_encode. Ex: JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_HEX_TAG|JSON_HEX_APOS
* @param depth is to set the recursion depth. Default is 512.
*
* @return string
*/
Expand All @@ -81,12 +81,12 @@ public static function encode($data,$withlog=false,$pretty=false,$options=0,$dep
* Safest way to encode Array string or value to json (safe but slower because conversion)
* When the time to use this function: If you want to display json data which is retrieve from database that maybe contains invalid utf8 chars.
*
* @var data is the array string or value
* @var withlog if set to true then will append logger data. Default is false.
* @var pretty is to make ouput json nice, clean and readable. Default is false for perfomance speed reason.
* @var ansii if set to true then conversion to utf8 is more reliable because will work for ANSII chars. Default is set to false for performance reason.
* @var options is to set the options of json_encode. Ex: JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_HEX_TAG|JSON_HEX_APOS
* @var depth is to set the recursion depth. Default is 512.
* @param data is the array string or value
* @param withlog if set to true then will append logger data. Default is false.
* @param pretty is to make ouput json nice, clean and readable. Default is false for perfomance speed reason.
* @param ansii if set to true then conversion to utf8 is more reliable because will work for ANSII chars. Default is set to false for performance reason.
* @param options is to set the options of json_encode. Ex: JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_HEX_TAG|JSON_HEX_APOS
* @param depth is to set the recursion depth. Default is 512.
*
* @return string
*/
Expand All @@ -101,10 +101,10 @@ public static function safeEncode($data,$withlog=false,$pretty=false,$ansii=fals
/**
* Decode json string (if fail will return null)
*
* @var json is the json string
* @var assoc if set to true then will return as array()
* @var depth is to set the recursion depth. Default is 512.
* @var options is to set the options of json_decode. Ex: JSON_BIGINT_AS_STRING|JSON_OBJECT_AS_ARRAY
* @param json is the json string
* @param assoc if set to true then will return as array()
* @param depth is to set the recursion depth. Default is 512.
* @param options is to set the options of json_decode. Ex: JSON_BIGINT_AS_STRING|JSON_OBJECT_AS_ARRAY
*
* @return mixed stdClass/array
*/
Expand All @@ -120,9 +120,9 @@ public static function decode($json,$assoc=false,$depth=512,$options=0){
* - So this function is make you easier to modify the json string to become nice json data structure automatically.
* - This function is well tested at here >> https://3v4l.org/IWkjn
*
* @var data is the data array
* @var jsonfield is the field which is contains json string
* @var setnewfield is to put the result of modified json string in new field
* @param data is the data array
* @param jsonfield is the field which is contains json string
* @param setnewfield is to put the result of modified json string in new field
* @return mixed array or string (if the $data is string then will return string)
*/
public static function modifyJsonStringInArray($data,$jsonfield,$setnewfield=""){
Expand Down Expand Up @@ -168,11 +168,33 @@ public static function modifyJsonStringInArray($data,$jsonfield,$setnewfield="")
return $data;
}

/**
* Concatenate json data
* Example: https://3v4l.org/fXjhd
*
* @param data is the json string or array value
* @param escape if set to false then json data will not escaped. Default is true.
* @param options is to set the options of json_encode (for data array only). Ex: JSON_UNESCAPED_SLASHES|JSON_UNESCAPED_UNICODE
* @param depth is to set the recursion depth. Default is 512.
* @return string
*/
public static function concatenate($data,$escape=true,$options=0,$depth=512){
if(!empty($data)){
if(is_array($data)){
if($escape) return addcslashes(json_encode($data,$options,$depth),"\"'\n");
return json_encode($data,$options,$depth);
}
if($escape) return addcslashes($data,"\"'\n");
return $data;
}
if($escape) return '';
return '""';
}

/**
* Determine is valid json or not
*
* @var data is the array string or value
* @param data is the array string or value
*
* @return bool
*/
Expand All @@ -189,8 +211,8 @@ public static function isValid($data=null) {
* - This is because if you do in php, json_encode function will auto giving backslash in your string if it contains invalid chars.
* - You have to create regex to convert char to invalid utf-8 for test in array
*
* @var string is the array string or value
* @var lite if set to true will hide the additional data about error in json. Default is false.
* @param string is the array string or value
* @param lite if set to true will hide the additional data about error in json. Default is false.
*
* @return string json output formatted
*/
Expand All @@ -203,8 +225,8 @@ public static function debug_encode($string,$lite=false){
/**
* Debugger to test json decode
*
* @var json is the json string
* @var lite if set to true will hide the additional data about error in json. Default is false.
* @param json is the json string
* @param lite if set to true will hide the additional data about error in json. Default is false.
*
* @return string json output formatted
*/
Expand All @@ -220,9 +242,9 @@ public static function debug_decode($json,$lite=false){
/**
* Case error message about json
*
* @var jsonlasterror is the json_last_error() function
* @var content is the additional data about error in json
* @var lite if set to true will hide the additional data about error in json. Default is false.
* @param jsonlasterror is the json_last_error() function
* @param content is the additional data about error in json
* @param lite if set to true will hide the additional data about error in json. Default is false.
*
* @return array
*/
Expand Down
2 changes: 1 addition & 1 deletion src/classes/UniversalCache.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static function optionRedis(){
/**
* Convert string to valid UTF8 chars (slower but support ANSII)
*
* @var string is the array string or value
* @param string is the array string or value
*
* @return string
*/
Expand Down
4 changes: 2 additions & 2 deletions src/classes/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ private function isFilenameInExplorer(){

/**
* Force stream inline or attachment to protect from hotlinking
* @var $stream = deliver content. Default true means inline
* @var $age = this is the max age for cache control in header
* @param $stream = deliver content. Default true means inline
* @param $age = this is the max age for cache control in header
* @return result stream data or process in json encoded data
*/
public function forceStream($stream=true,$age=86400){
Expand Down
14 changes: 7 additions & 7 deletions src/classes/Validation.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class Validation {
/**
* Sanitizer string and only accept alphabet
*
* @var $string
* @param $string
*
* @return string
*/
Expand All @@ -31,7 +31,7 @@ public static function alphabetOnly($string){
/**
* Sanitizer string and only accept integer
*
* @var string is the value
* @param string is the value
*
* @return string
*/
Expand All @@ -42,7 +42,7 @@ public static function integerOnly($string){
/**
* Sanitizer string and only accept numeric
*
* @var string is the value
* @param string is the value
*
* @return string
*/
Expand All @@ -53,7 +53,7 @@ public static function numericOnly($string){
/**
* Sanitizer string and only accept numeric abs
*
* @var string is the value
* @param string is the value
*
* @return string
*/
Expand All @@ -64,7 +64,7 @@ public static function numericAbsOnly($string){
/**
* Determine if string is numeric
*
* @var string is the value
* @param string is the value
*
* @return bool
*/
Expand All @@ -75,7 +75,7 @@ public static function isNumeric($string){
/**
* Determine if string is decimal
*
* @var string is the value
* @param string is the value
*
* @return bool
*/
Expand All @@ -87,7 +87,7 @@ public static function isDecimal($string){
/**
* Determine if string is decimal only
*
* @var string is the value
* @param string is the value
*
* @return bool
*/
Expand Down
6 changes: 3 additions & 3 deletions src/classes/middleware/ValidateParam.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class ValidateParam
/**
* Constructor
*
* @var parameter is the body of the request parameter
* @var between is the min and max chars length of the parameter. Default is empty means unlimited chars and allow empty chars.
* @var regex is to validate the value of the parameter. See the validateRegex function for the shortcut regex. Default is empty.
* @param parameter is the body of the request parameter
* @param between is the min and max chars length of the parameter. Default is empty means unlimited chars and allow empty chars.
* @param regex is to validate the value of the parameter. See the validateRegex function for the shortcut regex. Default is empty.
*/
public function __construct($parameter,$between='',$regex=''){
$this->parameter = $parameter;
Expand Down
6 changes: 3 additions & 3 deletions src/classes/middleware/ValidateParamJSON.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class ValidateParamJSON
/**
* Constructor
*
* @var parameter is the body of the request parameter
* @var between is the min and max chars length of the parameter. Default is empty means unlimited chars and allow empty chars.
* @var regex is to validate the value of the parameter. See the validateRegex function for the shortcut regex. Default is empty.
* @param parameter is the body of the request parameter
* @param between is the min and max chars length of the parameter. Default is empty means unlimited chars and allow empty chars.
* @param regex is to validate the value of the parameter. See the validateRegex function for the shortcut regex. Default is empty.
*/
public function __construct($parameter,$between='',$regex=''){
$this->parameter = $parameter;
Expand Down
6 changes: 3 additions & 3 deletions src/classes/middleware/ValidateParamURL.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ class ValidateParamURL
/**
* Constructor
*
* @var parameter is the url parameter of the request. Example http://xxx.com/?example=abcdef&count=123456 => "example" and "count" is the url parameter after the "?" letter.
* @var between is the min and max chars length of the parameter. Default is empty means unlimited chars and allow empty chars.
* @var regex is to validate the value of the parameter. See the validateRegex function for the shortcut regex. Default is empty.
* @param parameter is the url parameter of the request. Example http://xxx.com/?example=abcdef&count=123456 => "example" and "count" is the url parameter after the "?" letter.
* @param between is the min and max chars length of the parameter. Default is empty means unlimited chars and allow empty chars.
* @param regex is to validate the value of the parameter. See the validateRegex function for the shortcut regex. Default is empty.
*/
public function __construct($parameter,$between='',$regex=''){
$this->parameter = $parameter;
Expand Down

0 comments on commit cf30f23

Please sign in to comment.