Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 71e34848d9 | |||
| 90d76bbd6c | |||
| f275180571 |
@@ -6,3 +6,4 @@ tools/
|
||||
**/.env
|
||||
**/.target
|
||||
package-lock.json
|
||||
build/
|
||||
|
||||
@@ -49,6 +49,7 @@ php_version="";
|
||||
no_php_version=0;
|
||||
use_composer=0;
|
||||
opt_generate_coverage="";
|
||||
opt_generate_coverage_html="";
|
||||
while [ -n "${1-}" ]; do
|
||||
case "${1}" in
|
||||
-t | --testdox)
|
||||
@@ -65,6 +66,10 @@ while [ -n "${1-}" ]; do
|
||||
opt_generate_coverage="--coverage-text";
|
||||
shift
|
||||
;;
|
||||
--coverage-report)
|
||||
opt_generate_coverage_html="--coverage-html build/coverage-report";
|
||||
shift
|
||||
;;
|
||||
-p | --php)
|
||||
php_version="${2-}";
|
||||
shift
|
||||
@@ -114,6 +119,7 @@ PHPUNIT_CALL+=(
|
||||
"${opt_testdox}"
|
||||
"${opt_verbose}"
|
||||
"${opt_generate_coverage}"
|
||||
"${opt_generate_coverage_html}"
|
||||
"-c" "${PHPUNIT_CONFIG}"
|
||||
"${BASE_PATH}4dev/tests/"
|
||||
);
|
||||
|
||||
+5
-2
@@ -1,8 +1,11 @@
|
||||
// https://www.typescriptlang.org/tsconfig/#compilerOptions
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "ESNext",
|
||||
"moduleResolution": "Node",
|
||||
// if "bundler"
|
||||
// "module": "ESNext",
|
||||
"module": "NodeNext",
|
||||
// "bundler" (front), "nodenext" or "node16"
|
||||
"moduleResolution": "nodenext",
|
||||
"target": "ES2020",
|
||||
"jsx": "react",
|
||||
"checkJs": true,
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
<include>
|
||||
<directory suffix=".php">./www/lib/CoreLibs</directory>
|
||||
</include>
|
||||
<!-- <report>
|
||||
<html outputDirectory="build/coverage-report"/>
|
||||
</report> -->
|
||||
</coverage>
|
||||
<!-- <source>
|
||||
<include>
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@
|
||||
]
|
||||
},
|
||||
"repositories": {
|
||||
"git.egplusww.jp.Composer": {
|
||||
"packages.omnicomproduction.jp.Composer": {
|
||||
"type": "composer",
|
||||
"url": "https://packages.omnicomproduction.jp/api/packages/Composer/composer"
|
||||
}
|
||||
|
||||
@@ -811,6 +811,87 @@ class ArrayHandler
|
||||
);
|
||||
return $in_array;
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: move to CoreLibs ArrayCombined
|
||||
* return one random entry from an array (value)
|
||||
* the return entry is null if the incoming array is empty
|
||||
* the array can also be an array of arrays
|
||||
*
|
||||
* @param array<mixed> $array
|
||||
* @return string|int|float|bool|array<mixed>|null
|
||||
*/
|
||||
public static function getRandomEntryFromArray(array $array): string|int|float|bool|array|null
|
||||
{
|
||||
if (empty($array)) {
|
||||
return null;
|
||||
}
|
||||
$random_index = array_rand($array);
|
||||
return $array[$random_index];
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: move to CoreLibs ArrayCombined
|
||||
* find and remove one value
|
||||
* on default removes only the first entry
|
||||
* on default does not strict compare
|
||||
*
|
||||
* @param array<mixed> $array
|
||||
* @param string|int|float|bool|array<mixed> $value
|
||||
* @param bool $strict [false]
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function removeArrayEntryByValue(
|
||||
array $array,
|
||||
string|int|float|bool|array $value,
|
||||
bool $strict = false,
|
||||
): array {
|
||||
return array_filter($array, function ($element) use ($value, $strict) {
|
||||
return $strict ?
|
||||
$element !== $value :
|
||||
$element != $value;
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: move to CoreLibs ArrayCombined
|
||||
* add a string to each element in an array, default is at the end of the value,
|
||||
* can be switched with the prefix flag
|
||||
*
|
||||
* @param array<string> $array
|
||||
* @param string $string_to_add
|
||||
* @param bool $prefix [false]
|
||||
* @return array<string>
|
||||
*/
|
||||
public static function addStringToEachValueInArray(array $array, string $string_to_add, bool $prefix = false): array
|
||||
{
|
||||
return array_map(function ($value) use ($string_to_add, $prefix) {
|
||||
return $prefix ?
|
||||
$string_to_add . $value :
|
||||
$value . $string_to_add;
|
||||
}, $array);
|
||||
}
|
||||
|
||||
/**
|
||||
* sort by key any array, even if it is nested
|
||||
*
|
||||
* @param array<mixed> $data
|
||||
* @return array<mixed>
|
||||
*/
|
||||
public static function createSortedArrayByKey(array $data): array
|
||||
{
|
||||
// Sort by keys
|
||||
ksort($data);
|
||||
|
||||
// Recursively sort nested arrays
|
||||
foreach ($data as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$data[$key] = self::createSortedArrayByKey($value);
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
// __END__
|
||||
|
||||
@@ -51,7 +51,7 @@ enum Convert: int
|
||||
/**
|
||||
* Get internal name from int value
|
||||
*
|
||||
* @param int $value
|
||||
* @param int $value
|
||||
* @return self
|
||||
*/
|
||||
public static function fromValue(int $value): self
|
||||
|
||||
@@ -63,7 +63,7 @@ enum Flag: int
|
||||
/**
|
||||
* Get internal name from int value
|
||||
*
|
||||
* @param int $value
|
||||
* @param value-of<self::VALUES> $value
|
||||
* @return self
|
||||
*/
|
||||
public static function fromValue(int $value): self
|
||||
|
||||
Reference in New Issue
Block a user