Skip to content

Commit 6e4d0cc

Browse files
authored
Merge pull request #50 from nguyenanhung/develop
Release version 1.6.2
2 parents c21869b + fd53920 commit 6e4d0cc

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+2699
-908
lines changed

.github/workflows/php.yml

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,28 @@
22
name: Testing CodeIgniter Basic Helper by HungNG
33
on: [ push, pull_request ]
44
jobs:
5-
build:
6-
strategy:
7-
matrix:
8-
operating-system: [ 'ubuntu-latest', 'ubuntu-20.04', 'ubuntu-22.04', 'macos-latest', 'macos-11', 'macos-12' ]
9-
php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2' ]
10-
runs-on: ${{ matrix.operating-system }}
11-
steps:
12-
- name: Checkout
13-
uses: actions/checkout@v3
14-
- name: Setup PHP, with composer and extensions
15-
uses: shivammathur/setup-php@v2 # From https://github.com/shivammathur/setup-php
16-
with:
17-
php-version: ${{ matrix.php-versions }}
18-
extensions: mbstring, intl, curl, json, openssl, iconv, bcmath, xml
19-
- name: Get composer cache directory
20-
id: composer-cache
21-
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
22-
- name: Cache dependencies
23-
uses: actions/cache@v3
24-
with:
25-
path: ${{ steps.composer-cache.outputs.dir }}
26-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
27-
restore-keys: ${{ runner.os }}-composer-
28-
- name: Install dependencies
29-
run: composer install --no-dev --no-progress --prefer-dist --optimize-autoloader
5+
build:
6+
strategy:
7+
matrix:
8+
operating-system: [ 'ubuntu-latest', 'ubuntu-20.04', 'ubuntu-22.04' ]
9+
php-versions: [ '5.6', '7.0', '7.1', '7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3' ]
10+
runs-on: ${{ matrix.operating-system }}
11+
steps:
12+
- name: Checkout
13+
uses: actions/checkout@v3
14+
- name: Setup PHP, with composer and extensions
15+
uses: shivammathur/setup-php@v2 # From https://github.com/shivammathur/setup-php
16+
with:
17+
php-version: ${{ matrix.php-versions }}
18+
extensions: mbstring, intl, curl, json, openssl, iconv, bcmath, xml
19+
- name: Get composer cache directory
20+
id: composer-cache
21+
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT
22+
- name: Cache dependencies
23+
uses: actions/cache@v3
24+
with:
25+
path: ${{ steps.composer-cache.outputs.dir }}
26+
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.json') }}
27+
restore-keys: ${{ runner.os }}-composer-
28+
- name: Install dependencies
29+
run: composer install --no-dev --no-progress --prefer-dist --optimize-autoloader

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"nguyenanhung/basic-miscellaneous-helper": "^2.0 || ^1.0"
3434
},
3535
"require-dev": {
36-
"nguyenanhung/my-debug": "^3.0 || ^2.0",
36+
"nguyenanhung/my-debug": "^4.0 || ^3.0 || ^2.0",
3737
"nguyenanhung/nanoid-helper": "^2.0 || ^1.0",
3838
"nguyenanhung/json-helper": "^2.0 || ^1.0",
3939
"nguyenanhung/image": "^3.0 || ^2.0 || ^1.0",

helpers/alphaid_helper.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Project codeigniter-basic-helper
45
* Created by PhpStorm
@@ -7,7 +8,7 @@
78
* Date: 09/11/2021
89
* Time: 08:52
910
*/
10-
if (!function_exists('generateAlphaId')) {
11+
if ( ! function_exists('generateAlphaId')) {
1112
/**
1213
* Translates a number to a short alphanumeric version
1314
*
@@ -50,10 +51,10 @@
5051
* but I haven't really dugg into this. If you have more info on those
5152
* matters feel free to leave a comment.
5253
*
53-
* @param mixed $in String or long input to translate
54-
* @param bool $to_num Reverses translation when true
55-
* @param mixed $pad_up Number or boolean padds the result up to a specified length
56-
* @param mixed $passKey Supplying a password makes it harder to calculate the original ID
54+
* @param mixed $in String or long input to translate
55+
* @param bool $to_num Reverses translation when true
56+
* @param mixed $pad_up Number or boolean padds the result up to a specified length
57+
* @param mixed $passKey Supplying a password makes it harder to calculate the original ID
5758
*
5859
* @return string string or long
5960
* @author Kevin van Zonneveld <kevin@vanzonneveld.net>

helpers/array_helper.php

Lines changed: 41 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<?php
2+
23
/**
34
* Project codeigniter-basic-helper
45
* Created by PhpStorm
@@ -7,11 +8,11 @@
78
* Date: 08/07/2021
89
* Time: 01:12
910
*/
10-
if (!function_exists('arrayToObject')) {
11+
if ( ! function_exists('arrayToObject')) {
1112
/**
1213
* Function arrayToObject
1314
*
14-
* @param array|mixed $array
15+
* @param array|mixed $array
1516
*
1617
* @return array|false|\stdClass
1718
* @author : 713uk13m <dev@nguyenanhung.com>
@@ -20,14 +21,14 @@
2021
*/
2122
function arrayToObject($array = array())
2223
{
23-
if (!is_array($array)) {
24+
if ( ! is_array($array)) {
2425
return $array;
2526
}
2627
$object = new stdClass();
2728
$countArray = count($array);
2829
if ($countArray > 0) {
2930
foreach ($array as $name => $value) {
30-
if (!empty($name)) {
31+
if ( ! empty($name)) {
3132
$object->$name = arrayToObject($value);
3233
}
3334
}
@@ -36,13 +37,13 @@ function arrayToObject($array = array())
3637
return false;
3738
}
3839
}
39-
if (!function_exists('arrayToXml')) {
40+
if ( ! function_exists('arrayToXml')) {
4041
/**
4142
* Function arrayToXml
4243
*
43-
* @param array|mixed $array
44-
* @param string $namespace
45-
* @param mixed $file_output
44+
* @param array|mixed $array
45+
* @param string $namespace
46+
* @param mixed $file_output
4647
*
4748
* @return bool|string|null
4849
* @throws \Exception
@@ -53,15 +54,18 @@ function arrayToObject($array = array())
5354
function arrayToXml($array = array(), $namespace = '', $file_output = null)
5455
{
5556
if (class_exists('SimpleXMLElement')) {
56-
$xml_object = new SimpleXMLElement("<?xml version=\"1.0\"?><" . $namespace . "></" . $namespace . ">"); // creating object of SimpleXMLElement
57+
$xml_object = new SimpleXMLElement(
58+
"<?xml version=\"1.0\"?><" . $namespace . "></" . $namespace . ">"
59+
); // creating object of SimpleXMLElement
5760
convertArrayToXml($array, $xml_object); // function call to convert array to xml
58-
$xml_file = $file_output !== null ? $xml_object->asXML($file_output) : $xml_object->asXML(); // saving generated xml file
59-
return !empty($xml_file) ? $xml_file : null;
61+
$xml_file = $file_output !== null ? $xml_object->asXML($file_output) : $xml_object->asXML(
62+
); // saving generated xml file
63+
return ! empty($xml_file) ? $xml_file : null;
6064
}
6165
return null;
6266
}
6367
}
64-
if (!function_exists('convertArrayToXml')) {
68+
if ( ! function_exists('convertArrayToXml')) {
6569
/**
6670
* Function convertArrayToXml
6771
*
@@ -76,7 +80,7 @@ function convertArrayToXml($array, &$SimpleXMLElement)
7680
{
7781
foreach ($array as $key => $value) {
7882
if (is_array($value)) {
79-
if (!is_numeric($key)) {
83+
if ( ! is_numeric($key)) {
8084
$subNode = $SimpleXMLElement->addChild((string)$key);
8185
} else {
8286
$subNode = $SimpleXMLElement->addChild("item" . $key);
@@ -88,7 +92,7 @@ function convertArrayToXml($array, &$SimpleXMLElement)
8892
}
8993
}
9094
}
91-
if (!function_exists('removeArrayElementWithValue')) {
95+
if ( ! function_exists('removeArrayElementWithValue')) {
9296
/**
9397
* Function removeArrayElementWithValue - Loại bỏ 1 giá trị trong array theo key và value
9498
*
@@ -111,7 +115,7 @@ function removeArrayElementWithValue($array, $key, $value)
111115
return $array;
112116
}
113117
}
114-
if (!function_exists('arrayRecursiveDiff')) {
118+
if ( ! function_exists('arrayRecursiveDiff')) {
115119
/**
116120
* Function arrayRecursiveDiff - Diff 2 array bằng đệ quy
117121
*
@@ -143,7 +147,7 @@ function arrayRecursiveDiff($aArray1, $aArray2)
143147
return $aReturn;
144148
}
145149
}
146-
if (!function_exists('arrayIsAssoc')) {
150+
if ( ! function_exists('arrayIsAssoc')) {
147151
/**
148152
* Function arrayIsAssoc - Detects if the given value is an associative array.
149153
*
@@ -167,21 +171,21 @@ function arrayRecursiveDiff($aArray1, $aArray2)
167171
* // bool(true)
168172
* ```
169173
*
170-
* @param array $array
174+
* @param array $array
171175
* Any type of array.
172176
*
173177
* @return bool
174178
* True if the array is associative, false otherwise.
175179
*/
176180
function arrayIsAssoc($array)
177181
{
178-
if (!is_array($array) || $array === array()) {
182+
if ( ! is_array($array) || $array === array()) {
179183
return false;
180184
}
181185
return array_keys($array) !== range(0, count($array) - 1);
182186
}
183187
}
184-
if (!function_exists('arrayFirstElement')) {
188+
if ( ! function_exists('arrayFirstElement')) {
185189
/**
186190
* Function arrayFirstElement - Returns the first element of an array.
187191
*
@@ -206,7 +210,7 @@ function arrayIsAssoc($array)
206210
* // bar
207211
* ```
208212
*
209-
* @param array $array
213+
* @param array $array
210214
* The concerned array.
211215
*
212216
* @return mixed
@@ -218,7 +222,7 @@ function arrayFirstElement($array)
218222
return $array[array_keys($array)[0]];
219223
}
220224
}
221-
if (!function_exists('arrayLastElement')) {
225+
if ( ! function_exists('arrayLastElement')) {
222226
/**
223227
* Function arrayLastElement - Returns the last element of an array.
224228
*
@@ -243,7 +247,7 @@ function arrayFirstElement($array)
243247
* // qux
244248
* ```
245249
*
246-
* @param array $array
250+
* @param array $array
247251
* The concerned array.
248252
*
249253
* @return mixed
@@ -254,7 +258,7 @@ function arrayLastElement($array)
254258
return $array[array_keys($array)[count($array) - 1]];
255259
}
256260
}
257-
if (!function_exists('arrayGetElement')) {
261+
if ( ! function_exists('arrayGetElement')) {
258262
/**
259263
* Function arrayGetElement - Gets a value in an array by dot notation for the keys.
260264
*
@@ -281,9 +285,9 @@ function arrayLastElement($array)
281285
* // foobar
282286
* ```
283287
*
284-
* @param string $key
288+
* @param string $key
285289
* The key by dot notation.
286-
* @param array $array
290+
* @param array $array
287291
* The array to search in.
288292
*
289293
* @return mixed
@@ -295,7 +299,7 @@ function arrayGetElement($key, $array)
295299
$keys = explode('.', $key);
296300
while (count($keys) >= 1) {
297301
$k = array_shift($keys);
298-
if (!isset($array[$k])) {
302+
if ( ! isset($array[$k])) {
299303
return null;
300304
}
301305
if (count($keys) === 0) {
@@ -307,7 +311,7 @@ function arrayGetElement($key, $array)
307311
return null;
308312
}
309313
}
310-
if (!function_exists('arraySetElement')) {
314+
if ( ! function_exists('arraySetElement')) {
311315
/**
312316
* Function arraySetElement - Sets a value in an array using the dot notation.
313317
*
@@ -359,27 +363,27 @@ function arrayGetElement($key, $array)
359363
* // )
360364
* ```
361365
*
362-
* @param string $key
366+
* @param string $key
363367
* The key to set using dot notation.
364-
* @param mixed $value
368+
* @param mixed $value
365369
* The value to set on the specified key.
366-
* @param array $array
370+
* @param array $array
367371
* The concerned array.
368372
*
369373
* @return bool
370374
* True if the new value was successfully set, false otherwise.
371375
*/
372376
function arraySetElement($key, $value, &$array)
373377
{
374-
if (is_string($key) && !empty($key)) {
378+
if (is_string($key) && ! empty($key)) {
375379
$keys = explode('.', $key);
376380
$arrTmp = &$array;
377381
while (count($keys) >= 1) {
378382
$k = array_shift($keys);
379-
if (!is_array($arrTmp)) {
383+
if ( ! is_array($arrTmp)) {
380384
$arrTmp = array();
381385
}
382-
if (!isset($arrTmp[$k])) {
386+
if ( ! isset($arrTmp[$k])) {
383387
$arrTmp[$k] = array();
384388
}
385389
if (count($keys) === 0) {
@@ -392,7 +396,7 @@ function arraySetElement($key, $value, &$array)
392396
return false;
393397
}
394398
}
395-
if (!function_exists('to_array')) {
399+
if ( ! function_exists('to_array')) {
396400
/**
397401
* Function to_array - Converts a string or an object to an array.
398402
*
@@ -429,7 +433,7 @@ function arraySetElement($key, $value, &$array)
429433
* // )
430434
* ```
431435
*
432-
* @param string|object $var
436+
* @param string|object $var
433437
* String or object.
434438
*
435439
* @return array|null
@@ -447,11 +451,11 @@ function to_array($var)
447451
return null;
448452
}
449453
}
450-
if (!function_exists('arrayToAttributes')) {
454+
if ( ! function_exists('arrayToAttributes')) {
451455
/**
452456
* Takes an array of attributes and turns it into a string for an html tag
453457
*
454-
* @param array $attr
458+
* @param array $attr
455459
*
456460
* @return string
457461
*/

0 commit comments

Comments
 (0)