diff --git a/www/admin/class_test.convert.colors.php b/www/admin/class_test.convert.colors.php index 6f809691..6754aa51 100644 --- a/www/admin/class_test.convert.colors.php +++ b/www/admin/class_test.convert.colors.php @@ -19,6 +19,8 @@ $LOG_FILE_ID = 'classTest-convert-colors'; ob_end_flush(); use CoreLibs\Convert\Colors; +use CoreLibs\Convert\Color\Color; +use CoreLibs\Convert\Color\Coordinates; use CoreLibs\Debug\Support as DgS; use CoreLibs\Convert\SetVarType; @@ -29,6 +31,36 @@ $log = new CoreLibs\Logging\Logging([ ]); $color_class = 'CoreLibs\Convert\Colors'; +/** + * print out a color block with info + * + * @param string $color + * @param string $text + * @param string $text_add + * @return string + */ +function display(string $color, string $text, string $text_add): string +{ + $css = 'margin:5px;padding:50px;' + . 'width:10%;' + . 'text-align:center;' + . 'color:white;text-shadow: 0 0 5px black;font-weight:bold;'; + $template = << + {TEXT} + + HTML; + return str_replace( + ["{COLOR}", "{TEXT}", "{CSS}"], + [ + $color, + $text . (!empty($text_add) ? '
' . $text_add : ''), + $css + ], + $template + ); +} + $PAGE_NAME = 'TEST CLASS: CONVERT COLORS'; print ""; print "" . $PAGE_NAME . ""; @@ -36,32 +68,82 @@ print ""; print '
Class Test Master
'; print '

' . $PAGE_NAME . '

'; +// out of bounds test + // define a list of from to color sets for conversion test +$hwb = Color::hsbToHwb(new Coordinates\HSB([ + 160, + 0, + 50, +])); +print "HWB: " . DgS::printAr($hwb) . "
"; +$hsb = Color::hwbToHsb($hwb); +print "HSB: " . DgS::printAr($hsb) . "
"; + +$oklch = Color::rgbToOkLch(Coordinates\RGB::create([ + 250, + 0, + 0 +])); +print "OkLch: " . DgS::printAr($oklch) . "
"; +$rgb = Color::okLchToRgb($oklch); +print "OkLch -> RGB: " . DgS::printAr($rgb) . "
"; + +$oklab = Color::rgbToOkLab(Coordinates\RGB::create([ + 250, + 0, + 0 +])); +print "OkLab: " . DgS::printAr($oklab) . "
"; +print display($oklab->toCssString(), $oklab->toCssString(), 'Oklab'); +$rgb = Color::okLabToRgb($oklab); +print "OkLab -> RGB: " . DgS::printAr($rgb) . "
"; +print display($rgb->toCssString(), $rgb->toCssString(), 'OkLab to RGB'); + +$rgb = Coordinates\RGB::create([250, 100, 10])->toLinear(); +print "RGBlinear: " . DgS::printAr($rgb) . "
"; +$rgb = Coordinates\RGB::create([0, 0, 0])->toLinear(); +print "RGBlinear: " . DgS::printAr($rgb) . "
"; + +$cie_lab = Color::okLabToLab($oklab); +print "CieLab: " . DgS::printAr($cie_lab) . "
"; +print display($cie_lab->toCssString(), $cie_lab->toCssString(), 'OkLab to Cie Lab'); + +$rgb = Coordinates\RGB::create([0, 0, 60]); +$hsb = Color::rgbToHsb($rgb); +$rgb_b = Color::hsbToRgb($hsb); +print "RGB: " . DgS::printAr($rgb) . "
"; +print "RGB->HSB: " . DgS::printAr($hsb) . "
"; +print "HSB->RGB: " . DgS::printAr($rgb_b) . "
"; + +$hsl = Coordinates\HSL::create([0, 20, 0]); +$hsb = Coordinates\HSB::create([0, 20, 0]); +$hsl_from_hsb = Color::hsbToHsl($hsb); +print "HSL from HSB: " . DgS::printAr($hsl_from_hsb) . "
"; + +print "
"; + // A(out of bounds) try { print "C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: " - . CoreLibs\Convert\Colors::rgb2hex(-1, -1, -1) . "
"; + . (new Coordinates\RGB([-1, -1, -1]))->returnAsHex() . "
"; } catch (\LengthException $e) { - print "*Exception: " . $e->getMessage() . "
" . $e . "
"; -} -try { - print "\$C::S/COLOR invalid rgb->hex (gray 125): -1, -1, -1: " - . $color_class::rgb2hex(-1, -1, -1) . "
"; -} catch (\LengthException $e) { - print "**Exception: " . $e->getMessage() . "
" . print_r($e, true) . "

"; + print "*Exception: " . $e->getMessage() . "
" . print_r($e, true) . "

"; } +print "
"; +print "

LEGACY

"; // B(valid) -$rgb = [10, 20, 30]; +$rgb = [50, 20, 30]; $hex = '#0a141e'; $hsb = [210, 67, 12]; $hsb_f = [210.5, 67.5, 12.5]; -$hsl = [210, 50, 7.8]; +$hsb = [210, 50, 7.8]; print "S::COLOR rgb->hex: $rgb[0], $rgb[1], $rgb[2]: " . Colors::rgb2hex($rgb[0], $rgb[1], $rgb[2]) . "
"; print "S::COLOR hex->rgb: $hex: " . DgS::printAr(SetVarType::setArray( Colors::hex2rgb($hex) )) . "
"; -print "C::S/COLOR rgb->hext: $hex: " . DgS::printAr(SetVarType::setArray( +print "C::S/COLOR rgb->hex: $hex: " . DgS::printAr(SetVarType::setArray( CoreLibs\Convert\Colors::hex2rgb($hex) )) . "
"; // C(to hsb/hsl) @@ -82,9 +164,9 @@ print "S::COLOR hsb_f->rgb: $hsb_f[0], $hsb_f[1], $hsb_f[2]: " . DgS::printAr(SetVarType::setArray( Colors::hsb2rgb($hsb_f[0], $hsb_f[1], $hsb_f[2]) )) . "
"; -print "S::COLOR hsl->rgb: $hsl[0], $hsl[1], $hsl[2]: " +print "S::COLOR hsl->rgb: $hsb[0], $hsb[1], $hsb[2]: " . DgS::printAr(SetVarType::setArray( - Colors::hsl2rgb($hsl[0], $hsl[1], $hsl[2]) + Colors::hsl2rgb($hsb[0], $hsb[1], $hsb[2]) )) . "
"; $hsb = [0, 0, 5]; @@ -93,16 +175,26 @@ print "S::COLOR hsb->rgb: $hsb[0], $hsb[1], $hsb[2]: " Colors::hsb2rgb($hsb[0], $hsb[1], $hsb[2]) )) . "
"; +print "
"; + // Random text $h = rand(0, 359); $s = rand(15, 70); $b = 100; $l = 50; print "RANDOM IN: H: " . $h . ", S: " . $s . ", B/L: " . $b . "/" . $l . "
"; -print "RANDOM hsb->rgb:
" . DgS::printAr(SetVarType::setArray(Colors::hsb2rgb($h, $s, $b))) . "

"; -print "RANDOM hsl->rgb:
" . DgS::printAr(SetVarType::setArray(Colors::hsl2rgb($h, $s, $l))) . "

"; +print "RANDOM hsb->rgb:
"
+	. DgS::printAr(SetVarType::setArray(Color::hsbToRgb(new Coordinates\HSB([$h, $s, $b])))) . "

"; +print "RANDOM hsl->rgb:
"
+	. DgS::printAr(SetVarType::setArray(Color::hslToRgb(new Coordinates\HSL([$h, $s, $l])))) . "

"; -// TODO: run compare check input must match output +print "
"; + +$rgb = [0, 0, 0]; +print "rgb 0,0,0: " . Dgs::printAr($rgb) . " => " + . Dgs::printAr(Color::rgbToHsb(new Coordinates\RGB([$rgb[0], $rgb[1], $rgb[2]]))) . "
"; + +print "
"; print ""; diff --git a/www/admin/class_test.math.php b/www/admin/class_test.math.php index 287dc78f..d3af1f39 100644 --- a/www/admin/class_test.math.php +++ b/www/admin/class_test.math.php @@ -23,7 +23,6 @@ $log = new CoreLibs\Logging\Logging([ 'log_file_id' => $LOG_FILE_ID, 'log_per_date' => true, ]); -$_math = new CoreLibs\Convert\Math(); $math_class = 'CoreLibs\Convert\Math'; // define a list of from to color sets for conversion test @@ -35,13 +34,9 @@ print ""; print '
Class Test Master
'; print '

' . $PAGE_NAME . '

'; -print "FCEIL: " . $_math->fceil(5.1234567890, 5) . "
"; -print "FLOORP: " . $_math->floorp(5123456, -3) . "
"; -print "FLOORP: " . $_math->floorp(5123456, -10) . "
"; -print "INITNUMERIC: " . $_math->initNumeric('123') . "
"; - print "S-FCEIL: " . $math_class::fceil(5.1234567890, 5) . "
"; print "S-FLOORP: " . $math_class::floorp(5123456, -3) . "
"; +print "S-FLOORP: " . $math_class::floorp(5123456, -10) . "
"; print "S-INITNUMERIC: " . $math_class::initNumeric(123) . "
"; print "S-INITNUMERIC: " . $math_class::initNumeric(123.456) . "
"; print "S-INITNUMERIC: " . $math_class::initNumeric('123') . "
"; diff --git a/www/admin/class_test.php b/www/admin/class_test.php index 6c173f18..a5032e9a 100644 --- a/www/admin/class_test.php +++ b/www/admin/class_test.php @@ -134,7 +134,7 @@ print "
READ _ENV ARRAY:
"; print Support::dumpVar(array_map('htmlentities', $_ENV)); // set + check edit access id $edit_access_id = 3; -if (is_object($login) && isset($login->loginGetAcl()['unit'])) { +if (isset($login->loginGetAcl()['unit'])) { print "ACL UNIT: " . print_r(array_keys($login->loginGetAcl()['unit']), true) . "
"; print "ACCESS CHECK: " . (string)$login->loginCheckEditAccess($edit_access_id) . "
"; if ($login->loginCheckEditAccess($edit_access_id)) { @@ -177,25 +177,23 @@ $log->debug('SOME MARK', 'Some error output'); // INTERNAL SET print "EDIT ACCESS ID: " . $backend->edit_access_id . "
"; -if (is_object($login)) { - // print "ACL:
".$backend->print_ar($login->loginGetAcl())."
"; - // $log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::dumpVar($login->loginGetAcl())); - // print "DEFAULT ACL:
".$backend->print_ar($login->default_acl_list)."
"; - // print "DEFAULT ACL:
".$backend->print_ar($login->default_acl_list)."
"; - // $result = array_flip( - // array_filter( - // array_flip($login->default_acl_list), - // function ($key) { - // if (is_numeric($key)) { - // return $key; - // } - // } - // ) - // ); - // print "DEFAULT ACL:
".$backend->print_ar($result)."
"; - // DEPRICATED CALL - // $backend->adbSetACL($login->loginGetAcl()); -} +// print "ACL:
".$backend->print_ar($login->loginGetAcl())."
"; +// $log->debug('ACL', "ACL: " . \CoreLibs\Debug\Support::dumpVar($login->loginGetAcl())); +// print "DEFAULT ACL:
".$backend->print_ar($login->default_acl_list)."
"; +// print "DEFAULT ACL:
".$backend->print_ar($login->default_acl_list)."
"; +// $result = array_flip( +// array_filter( +// array_flip($login->default_acl_list), +// function ($key) { +// if (is_numeric($key)) { +// return $key; +// } +// } +// ) +// ); +// print "DEFAULT ACL:
".$backend->print_ar($result)."
"; +// DEPRICATED CALL +// $backend->adbSetACL($login->loginGetAcl()); print "THIS HOST: " . HOST_NAME . ", with PROTOCOL: " . HOST_PROTOCOL . " is running SSL: " . HOST_SSL . "
"; print "DIR: " . DIR . "
"; diff --git a/www/admin/class_test.url-requests.curl.php b/www/admin/class_test.url-requests.curl.php index 87fa0053..c43ce781 100644 --- a/www/admin/class_test.url-requests.curl.php +++ b/www/admin/class_test.url-requests.curl.php @@ -40,11 +40,11 @@ $data = $client->get( 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' . '?other=get_a', [ - 'headers' => $client->prepareHeaders([ - 'test-header: ABC', - 'info-request-type: _GET', + 'headers' => [ + 'test-header' => 'ABC', + 'info-request-type' => '_GET', 'Funk-pop' => 'Semlly god' - ]), + ], 'query' => ['foo' => 'BAR'] ] ); @@ -78,11 +78,11 @@ $data = $client->request( . 'trunk/www/admin/UrlRequests.target.php' . '?other=get_a', [ - "headers" => $client->prepareHeaders([ - 'test-header: ABC', - 'info-request-type: _GET', + "headers" => [ + 'test-header' => 'ABC', + 'info-request-type' => '_GET', 'Funk-pop' => 'Semlly god' - ]), + ], "query" => ['foo' => 'BAR'], ], ); @@ -94,12 +94,12 @@ $data = $client->post( . '?other=post_a', [ 'body' => ['payload' => 'data post'], - 'headers' => $client->prepareHeaders([ - 'Content-Type: application/json', - 'Accept: application/json', - 'test-header: ABC', - 'info-request-type: _POST' - ]), + 'headers' => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_POST', + ], 'query' => ['foo' => 'BAR post'], ] ); @@ -111,16 +111,33 @@ $data = $client->request( . '?other=post_a', [ "body" => ['payload' => 'data post', 'request' => 'I am the request body'], - "headers" => $client->prepareHeaders([ - 'Content-Type: application/json', - 'Accept: application/json', - 'test-header: ABC', - 'info-request-type: _POST' - ]), + "headers" => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_POST', + ], "query" => ['foo' => 'BAR post'], ] ); print "[request] _POST RESPONSE:
" . print_r($data, true) . "
"; +print "
"; +$data = $client->request( + "post", + 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/UrlRequests.target.php' + . '?other=post_a', + [ + "body" => 'string body here', + "headers" => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_POST', + ], + "query" => ['foo' => 'BAR post'], + ] +); +print "[request|string body] _POST RESPONSE:
" . print_r($data, true) . "
"; print "
"; $data = $client->put( @@ -128,12 +145,12 @@ $data = $client->put( . '?other=put_a', [ "body" => ['payload' => 'data put'], - "headers" => $client->prepareHeaders([ - 'Content-Type: application/json', - 'Accept: application/json', - 'test-header: ABC', - 'info-request-type: _PUT' - ]), + "headers" => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_PUT', + ], 'query' => ['foo' => 'BAR put'], ] ); @@ -145,12 +162,12 @@ $data = $client->patch( . '?other=patch_a', [ "body" => ['payload' => 'data patch'], - "headers" => $client->prepareHeaders([ - 'Content-Type: application/json', - 'Accept: application/json', - 'test-header: ABC', - 'info-request-type: _PATCH' - ]), + "headers" => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_PATCH', + ], 'query' => ['foo' => 'BAR patch'], ] ); @@ -162,12 +179,12 @@ $data = $client->delete( . '?other=delete_no_body_a', [ "body" => null, - "headers" => $client->prepareHeaders([ - 'Content-Type: application/json', - 'Accept: application/json', - 'test-header: ABC', - 'info-request-type: _DELETE' - ]), + "headers" => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_DELETE', + ], "query" => ['foo' => 'BAR delete'], ] ); @@ -179,12 +196,12 @@ $data = $client->delete( . '?other=delete_body_a', [ "body" => ['payload' => 'data delete'], - "headers" => $client->prepareHeaders([ - 'Content-Type: application/json', - 'Accept: application/json', - 'test-header: ABC', - 'info-request-type: _DELETE' - ]), + "headers" => [ + 'Content-Type' => 'application/json', + 'Accept' => 'application/json', + 'test-header' => 'ABC', + 'info-request-type' => '_DELETE', + ], "query" => ['foo' => 'BAR delete'], ] ); @@ -294,6 +311,24 @@ try { } catch (Exception $e) { print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; } +print "AUTH REQUEST HEADER SET:
"; +try { + $uc = new Curl([ + "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', + "auth" => ["user", "pass", "basic"], + "headers" => [ + "Authorization" => "schmalztiegel", + "RunAuthTest" => "yes", + ] + ]); + $response = $uc->get('UrlRequests.target.php'); + print "AUTH REQUEST (HEADER):
" . print_r($response, true) . "
"; + print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; + print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; + print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; +} catch (Exception $e) { + print "Exception:
" . print_r(json_decode($e->getMessage(), true), true) . "

"; +} print "
"; $uc = new Curl([ @@ -308,6 +343,19 @@ print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; +print "
"; +$uc = new Curl([ + "base_uri" => 'https://soba.egplusww.jp/developers/clemens/core_data/php_libraries/trunk/www/admin/', + "headers" => [ + 'bar' => 'foo:bar' + ] +]); +$response = $uc->get('UrlRequests.target.php'); +print "HEADER SET TEST REQUEST:
" . print_r($response, true) . "
"; +print "[uc] SENT URL: " . $uc->getUrlSent() . "
"; +print "[uc] SENT URL PARSED:
" . print_r($uc->getUrlParsedSent(), true) . "
"; +print "[uc] SENT HEADERS:
" . print_r($uc->getHeadersSent(), true) . "
"; + print ""; // __END__ diff --git a/www/composer.lock b/www/composer.lock index 1dbafb80..170b44d1 100644 --- a/www/composer.lock +++ b/www/composer.lock @@ -8,11 +8,11 @@ "packages": [ { "name": "egrajp/corelibs-composer-all", - "version": "dev-master", + "version": "dev-development", "dist": { "type": "path", "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", - "reference": "5e6ba856391c357426b687cfacdb402e3e74fa0b" + "reference": "e318a4fb9a5a34894e2fbff2f110c6626c87be0e" }, "require": { "php": ">=8.2", @@ -21,6 +21,8 @@ "require-dev": { "egrajp/smarty-extended": "^4.3", "gullevek/dotenv": "dev-master", + "phan/phan": "^5.4", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9" }, "type": "library", diff --git a/www/vendor/composer/installed.json b/www/vendor/composer/installed.json index 527d4fb6..3a993cb6 100644 --- a/www/vendor/composer/installed.json +++ b/www/vendor/composer/installed.json @@ -2,12 +2,12 @@ "packages": [ { "name": "egrajp/corelibs-composer-all", - "version": "dev-master", - "version_normalized": "dev-master", + "version": "dev-development", + "version_normalized": "dev-development", "dist": { "type": "path", "url": "/storage/var/www/html/developers/clemens/core_data/composer-packages/CoreLibs-Composer-All", - "reference": "5e6ba856391c357426b687cfacdb402e3e74fa0b" + "reference": "e318a4fb9a5a34894e2fbff2f110c6626c87be0e" }, "require": { "php": ">=8.2", @@ -16,6 +16,8 @@ "require-dev": { "egrajp/smarty-extended": "^4.3", "gullevek/dotenv": "dev-master", + "phan/phan": "^5.4", + "phpstan/phpstan": "^1.12", "phpunit/phpunit": "^9" }, "type": "library", diff --git a/www/vendor/composer/installed.php b/www/vendor/composer/installed.php index 2fb396f4..4c8ae232 100644 --- a/www/vendor/composer/installed.php +++ b/www/vendor/composer/installed.php @@ -11,9 +11,9 @@ ), 'versions' => array( 'egrajp/corelibs-composer-all' => array( - 'pretty_version' => 'dev-master', - 'version' => 'dev-master', - 'reference' => '5e6ba856391c357426b687cfacdb402e3e74fa0b', + 'pretty_version' => 'dev-development', + 'version' => 'dev-development', + 'reference' => 'e318a4fb9a5a34894e2fbff2f110c6626c87be0e', 'type' => 'library', 'install_path' => __DIR__ . '/../egrajp/corelibs-composer-all', 'aliases' => array(), diff --git a/www/vendor/egrajp/corelibs-composer-all/.phan/config.php b/www/vendor/egrajp/corelibs-composer-all/.phan/config.php index 84e03646..5076c7f8 100644 --- a/www/vendor/egrajp/corelibs-composer-all/.phan/config.php +++ b/www/vendor/egrajp/corelibs-composer-all/.phan/config.php @@ -370,6 +370,7 @@ return [ 'file_list' => [ "./test/configs/config.php", "./test/configs/config.other.php", + "./test/configs/config.path.php", "./test/configs/config.master.php", ], ]; diff --git a/www/vendor/egrajp/corelibs-composer-all/composer.json b/www/vendor/egrajp/corelibs-composer-all/composer.json index 8cb94eea..f5d9ec12 100644 --- a/www/vendor/egrajp/corelibs-composer-all/composer.json +++ b/www/vendor/egrajp/corelibs-composer-all/composer.json @@ -20,6 +20,8 @@ "psr/log": "^3.0@dev" }, "require-dev": { + "phpstan/phpstan": "^1.12", + "phan/phan": "^5.4", "egrajp/smarty-extended": "^4.3", "gullevek/dotenv": "dev-master", "phpunit/phpunit": "^9" diff --git a/www/vendor/egrajp/corelibs-composer-all/phpstan-bootstrap.php b/www/vendor/egrajp/corelibs-composer-all/phpstan-bootstrap.php index 3d165225..5ca816c1 100755 --- a/www/vendor/egrajp/corelibs-composer-all/phpstan-bootstrap.php +++ b/www/vendor/egrajp/corelibs-composer-all/phpstan-bootstrap.php @@ -8,5 +8,6 @@ $_SERVER['HTTP_HOST'] = 'soba.tokyo.tequila.jp'; // for whatever reason it does not load that from the confing.master.php // for includes/admin_header.php define('BASE_NAME', ''); +define('CONTENT_PATH', ''); // __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/publish/last.published b/www/vendor/egrajp/corelibs-composer-all/publish/last.published index 9e31a52e..eea47571 100644 --- a/www/vendor/egrajp/corelibs-composer-all/publish/last.published +++ b/www/vendor/egrajp/corelibs-composer-all/publish/last.published @@ -1 +1 @@ -9.17.6.1 +9.18.1 diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Basic.php b/www/vendor/egrajp/corelibs-composer-all/src/Basic.php index 065ec63e..db57672a 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Basic.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Basic.php @@ -1139,118 +1139,6 @@ class Basic // *** BETTER PASSWORD OPTIONS END *** - // *** COLORS *** - // [!!! DEPRECATED !!!] - // moved to \CoreLibs\Convert\Colors - - /** - * converts a hex RGB color to the int numbers - * @param string $hexStr RGB hexstring - * @param bool $returnAsString flag to return as string - * @param string $seperator string seperator: default: "," - * @return string|array|bool false on error or array with RGB or - * a string with the seperator - * @deprecated use \CoreLibs\Convert\Colors::hex2rgb() instead - */ - public static function hex2rgb(string $hexStr, bool $returnAsString = false, string $seperator = ',') - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::hex2rgb()', E_USER_DEPRECATED); - return \CoreLibs\Convert\Colors::hex2rgb($hexStr, $returnAsString, $seperator); - } - - /** - * converts the rgb values from int data to the valid rgb html hex string - * optional can turn of leading # - * @param int $red red 0-255 - * @param int $green green 0-255 - * @param int $blue blue 0-255 - * @param bool $hex_prefix default true, prefix with "#" - * @return string|bool rgb in hex values with leading # if set - * @deprecated use \CoreLibs\Convert\Colors::rgb2hex() instead - */ - public static function rgb2hex(int $red, int $green, int $blue, bool $hex_prefix = true) - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hex()', E_USER_DEPRECATED); - return \CoreLibs\Convert\Colors::rgb2hex($red, $green, $blue, $hex_prefix); - } - - /** - * converts and int RGB to the HTML color string in hex format - * @param int $red red 0-255 - * @param int $green green 0-255 - * @param int $blue blue 0-255 - * @return string|bool hex rgb string - * @deprecated use rgb2hex instead - */ - public static function rgb2html(int $red, int $green, int $blue) - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hex()', E_USER_DEPRECATED); - // check that each color is between 0 and 255 - return \CoreLibs\Convert\Colors::rgb2hex($red, $green, $blue, true); - } - - /** - * converts RGB to HSB/V values - * returns: - * array with hue (0-360), sat (0-100%), brightness/value (0-100%) - * @param int $red red 0-255 - * @param int $green green 0-255 - * @param int $blue blue 0-255 - * @return array|bool Hue, Sat, Brightness/Value - * @deprecated use \CoreLibs\Convert\Colors::rgb2hsb() instead - */ - public static function rgb2hsb(int $red, int $green, int $blue) - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hsb()', E_USER_DEPRECATED); - return \CoreLibs\Convert\Colors::rgb2hsb($red, $green, $blue); - } - - /** - * converts HSB/V to RGB values RGB is full INT - * @param int $H hue 0-360 - * @param float $S saturation 0-1 (float) - * @param float $V brightness/value 0-1 (float) - * @return array|bool 0 red/1 green/2 blue array - * @deprecated use \CoreLibs\Convert\Colors::hsb2rgb() instead - */ - public static function hsb2rgb(int $H, float $S, float $V) - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::hsb2rgb()', E_USER_DEPRECATED); - return \CoreLibs\Convert\Colors::hsb2rgb($H, (int)round($S * 100), (int)round($V * 100)); - } - - /** - * converts a RGB (0-255) to HSL - * return: - * array with hue (0-360), saturation (0-100%) and luminance (0-100%) - * @param int $r red 0-255 - * @param int $g green 0-255 - * @param int $b blue 0-255 - * @return array|bool hue/sat/luminance - * @deprecated use \CoreLibs\Convert\Colors::rgb2hsl() instead - */ - public static function rgb2hsl(int $r, int $g, int $b) - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::rgb2hsl()', E_USER_DEPRECATED); - return \CoreLibs\Convert\Colors::rgb2hsb($r, $g, $b); - } - - /** - * converts an HSL to RGB - * @param int $h hue: 0-360 (degrees) - * @param float $s saturation: 0-1 - * @param float $l luminance: 0-1 - * @return array|bool red/blue/green 0-255 each - * @deprecated use \CoreLibs\Convert\Colors::hsl2rgb() instead - */ - public static function hsl2rgb(int $h, float $s, float $l) - { - trigger_error('Method ' . __METHOD__ . ' is deprecated, use \CoreLibs\Convert\Colors::hsl2rgb()', E_USER_DEPRECATED); - return \CoreLibs\Convert\Colors::hsl2rgb($h, $s * 100, $l * 100); - } - - // *** COLORS END *** - // *** EMAIL FUNCTIONS *** // [!!! DEPRECATED !!!] // Moved to \CoreLibs\Check\Email diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php index f9f56171..b24747be 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Colors.php @@ -17,6 +17,9 @@ declare(strict_types=1); namespace CoreLibs\Convert; +use CoreLibs\Convert\Color\Color; +use CoreLibs\Convert\Color\Coordinates; + class Colors { /** @@ -30,6 +33,7 @@ class Colors * @param bool $hex_prefix default true, prefix with "#" * @return string rgb in hex values with leading # if set, * @throws \LengthException If any argument is not in the range of 0~255 + * @deprecated v9.20.0 use: new Coordinates\RGB([$red, $green, $blue]))->returnAsHex(true/false for #) */ public static function rgb2hex( int $red, @@ -37,20 +41,7 @@ class Colors int $blue, bool $hex_prefix = true ): string { - $hex_color = ''; - if ($hex_prefix === true) { - $hex_color = '#'; - } - foreach (['red', 'green', 'blue'] as $color) { - // if not valid, abort - if ($$color < 0 || $$color > 255) { - throw new \LengthException('Argument value ' . $$color . ' for color ' . $color - . ' is not in the range of 0 to 255', 1); - } - // pad left with 0 - $hex_color .= str_pad(dechex($$color), 2, '0', STR_PAD_LEFT); - } - return $hex_color; + return (new Coordinates\RGB([$red, $green, $blue]))->returnAsHex($hex_prefix); } /** @@ -63,32 +54,29 @@ class Colors * or a string with the seperator * @throws \InvalidArgumentException if hex string is empty * @throws \UnexpectedValueException if the hex string value is not valid + * @deprecated v9.20.0 use: new Coordinates\RGB($hex_string) (build string/array from return data) */ public static function hex2rgb( string $hex_string, bool $return_as_string = false, string $seperator = ',' ): string|array { - $hex_string = preg_replace("/[^0-9A-Fa-f]/", '', $hex_string); // Gets a proper hex string - if (!is_string($hex_string)) { - throw new \InvalidArgumentException('hex_string argument cannot be empty', 1); - } $rgbArray = []; - if (strlen($hex_string) == 6) { - // If a proper hex code, convert using bitwise operation. - // No overhead... faster - $colorVal = hexdec($hex_string); - $rgbArray['r'] = 0xFF & ($colorVal >> 0x10); - $rgbArray['g'] = 0xFF & ($colorVal >> 0x8); - $rgbArray['b'] = 0xFF & $colorVal; - } elseif (strlen($hex_string) == 3) { - // If shorthand notation, need some string manipulations - $rgbArray['r'] = hexdec(str_repeat(substr($hex_string, 0, 1), 2)); - $rgbArray['g'] = hexdec(str_repeat(substr($hex_string, 1, 1), 2)); - $rgbArray['b'] = hexdec(str_repeat(substr($hex_string, 2, 1), 2)); - } else { - // Invalid hex color code - throw new \UnexpectedValueException('Invalid hex_string: ' . $hex_string, 2); + // rewrite to previous r/g/b key output + foreach ((new Coordinates\RGB($hex_string))->returnAsArray() as $p => $el) { + $k = ''; + switch ($p) { + case 0: + $k = 'r'; + break; + case 1: + $k = 'g'; + break; + case 2: + $k = 'b'; + break; + } + $rgbArray[$k] = (int)round($el); } // returns the rgb string or the associative array return $return_as_string ? implode($seperator, $rgbArray) : $rgbArray; @@ -105,42 +93,16 @@ class Colors * @param int $blue blue 0-255 * @return array Hue, Sat, Brightness/Value * @throws \LengthException If any argument is not in the range of 0~255 + * @deprecated v9.20.0 use: Color::rgbToHsb(...)->returnAsArray() will return float unrounded */ public static function rgb2hsb(int $red, int $green, int $blue): array { - // check that rgb is from 0 to 255 - foreach (['red', 'green', 'blue'] as $color) { - if ($$color < 0 || $$color > 255) { - throw new \LengthException('Argument value ' . $$color . ' for color ' . $color - . ' is not in the range of 0 to 255', 1); - } - $$color = $$color / 255; - } - - $MAX = max($red, $green, $blue); - $MIN = min($red, $green, $blue); - $HUE = 0; - - if ($MAX == $MIN) { - return [0, 0, round($MAX * 100)]; - } - if ($red == $MAX) { - $HUE = ($green - $blue) / ($MAX - $MIN); - } elseif ($green == $MAX) { - $HUE = 2 + (($blue - $red) / ($MAX - $MIN)); - } elseif ($blue == $MAX) { - $HUE = 4 + (($red - $green) / ($MAX - $MIN)); - } - $HUE *= 60; - if ($HUE < 0) { - $HUE += 360; - } - - return [ - (int)round($HUE), - (int)round((($MAX - $MIN) / $MAX) * 100), - (int)round($MAX * 100) - ]; + return array_map( + fn ($v) => (int)round($v), + Color::rgbToHsb( + new Coordinates\RGB([$red, $green, $blue]) + )->returnAsArray() + ); } /** @@ -153,80 +115,16 @@ class Colors * @param float $V brightness/value 0-100 (int) * @return array 0 red/1 green/2 blue array as 0-255 * @throws \LengthException If any argument is not in the valid range + * @deprecated v9.20.0 use: Color::hsbToRgb(...)->returnAsArray() will return float unrounded */ public static function hsb2rgb(float $H, float $S, float $V): array { - // check that H is 0 to 359, 360 = 0 - // and S and V are 0 to 1 - if ($H == 360) { - $H = 0; - } - if ($H < 0 || $H > 359) { - throw new \LengthException('Argument value ' . $H . ' for hue is not in the range of 0 to 359', 1); - } - if ($S < 0 || $S > 100) { - throw new \LengthException('Argument value ' . $S . ' for saturation is not in the range of 0 to 100', 2); - } - if ($V < 0 || $V > 100) { - throw new \LengthException('Argument value ' . $V . ' for brightness is not in the range of 0 to 100', 3); - } - // convert to internal 0-1 format - $S /= 100; - $V /= 100; - - if ($S == 0) { - $V = (int)round($V * 255); - return [$V, $V, $V]; - } - - $Hi = floor($H / 60); - $f = ($H / 60) - $Hi; - $p = $V * (1 - $S); - $q = $V * (1 - ($S * $f)); - $t = $V * (1 - ($S * (1 - $f))); - - switch ($Hi) { - case 0: - $red = $V; - $green = $t; - $blue = $p; - break; - case 1: - $red = $q; - $green = $V; - $blue = $p; - break; - case 2: - $red = $p; - $green = $V; - $blue = $t; - break; - case 3: - $red = $p; - $green = $q; - $blue = $V; - break; - case 4: - $red = $t; - $green = $p; - $blue = $V; - break; - case 5: - $red = $V; - $green = $p; - $blue = $q; - break; - default: - $red = 0; - $green = 0; - $blue = 0; - } - - return [ - (int)round($red * 255), - (int)round($green * 255), - (int)round($blue * 255) - ]; + return array_map( + fn ($v) => (int)round($v), + Color::hsbToRgb( + new Coordinates\HSB([$H, $S, $V]) + )->returnAsArray() + ); } /** @@ -239,50 +137,16 @@ class Colors * @param int $blue blue 0-255 * @return array hue/sat/luminance * @throws \LengthException If any argument is not in the range of 0~255 + * @deprecated v9.20.0 use: Color::rgbToHsl(...)->returnAsArray() will return float unrounded */ public static function rgb2hsl(int $red, int $green, int $blue): array { - // check that rgb is from 0 to 255 - foreach (['red', 'green', 'blue'] as $color) { - if ($$color < 0 || $$color > 255) { - throw new \LengthException('Argument value ' . $$color . ' for color ' . $color - . ' is not in the range of 0 to 255', 1); - } - $$color = $$color / 255; - } - - $min = min($red, $green, $blue); - $max = max($red, $green, $blue); - $chroma = $max - $min; - $sat = 0; - $hue = 0; - // luminance - $lum = ($max + $min) / 2; - - // achromatic - if ($chroma == 0) { - // H, S, L - return [0.0, 0.0, round($lum * 100, 1)]; - } else { - $sat = $chroma / (1 - abs(2 * $lum - 1)); - if ($max == $red) { - $hue = fmod((($green - $blue) / $chroma), 6); - if ($hue < 0) { - $hue = (6 - fmod(abs($hue), 6)); - } - } elseif ($max == $green) { - $hue = ($blue - $red) / $chroma + 2; - } elseif ($max == $blue) { - $hue = ($red - $green) / $chroma + 4; - } - $hue = $hue * 60; - // $sat = 1 - abs(2 * $lum - 1); - return [ - round($hue, 1), - round($sat * 100, 1), - round($lum * 100, 1) - ]; - } + return array_map( + fn ($v) => round($v, 1), + Color::rgbToHsl( + new Coordinates\RGB([$red, $green, $blue]) + )->returnAsArray() + ); } /** @@ -294,57 +158,16 @@ class Colors * @param float $lum luminance: 0-100 * @return array red/blue/green 0-255 each * @throws \LengthException If any argument is not in the valid range + * @deprecated v9.20.0 use: Color::hslToRgb(...)->returnAsArray() will return float unrounded */ public static function hsl2rgb(float $hue, float $sat, float $lum): array { - if ($hue == 360) { - $hue = 0; - } - if ($hue < 0 || $hue > 359) { - throw new \LengthException('Argument value ' . $hue . ' for hue is not in the range of 0 to 359', 1); - } - if ($sat < 0 || $sat > 100) { - throw new \LengthException('Argument value ' . $sat . ' for saturation is not in the range of 0 to 100', 2); - } - if ($lum < 0 || $lum > 100) { - throw new \LengthException('Argument value ' . $lum . ' for luminance is not in the range of 0 to 100', 3); - } - // calc to internal convert value for hue - $hue = (1 / 360) * $hue; - // convert to internal 0-1 format - $sat /= 100; - $lum /= 100; - // if saturation is 0 - if ($sat == 0) { - $lum = (int)round($lum * 255); - return [$lum, $lum, $lum]; - } else { - $m2 = $lum < 0.5 ? $lum * ($sat + 1) : ($lum + $sat) - ($lum * $sat); - $m1 = $lum * 2 - $m2; - $hueue = function ($base) use ($m1, $m2) { - // base = hue, hue > 360 (1) - 360 (1), else < 0 + 360 (1) - $base = $base < 0 ? $base + 1 : ($base > 1 ? $base - 1 : $base); - // 6: 60, 2: 180, 3: 240 - // 2/3 = 240 - // 1/3 = 120 (all from 360) - if ($base * 6 < 1) { - return $m1 + ($m2 - $m1) * $base * 6; - } - if ($base * 2 < 1) { - return $m2; - } - if ($base * 3 < 2) { - return $m1 + ($m2 - $m1) * ((2 / 3) - $base) * 6; - } - return $m1; - }; - - return [ - (int)round(255 * $hueue($hue + (1 / 3))), - (int)round(255 * $hueue($hue)), - (int)round(255 * $hueue($hue - (1 / 3))) - ]; - } + return array_map( + fn ($v) => round($v), + Color::hslToRgb( + new Coordinates\HSL([$hue, $sat, $lum]) + )->returnAsArray() + ); } } diff --git a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php index 205abbf1..41eb7463 100644 --- a/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php +++ b/www/vendor/egrajp/corelibs-composer-all/src/Convert/Math.php @@ -56,6 +56,178 @@ class Math return (float)$number; } } + + /** + * calc cube root + * + * @param float $number Number to cubic root + * @return float Calculated value + */ + public static function cbrt(float|int $number): float + { + return pow((float)$number, 1.0 / 3); + } + + /** + * use PHP_FLOAT_EPSILON to compare if two float numbers are matching + * + * @param float $x + * @param float $y + * @param float $epsilon [default=PHP_FLOAT_EPSILON] + * @return bool True equal + */ + public static function equalWithEpsilon(float $x, float $y, float $epsilon = PHP_FLOAT_EPSILON): bool + { + if (abs($x - $y) < $epsilon) { + return true; + } + return false; + } + + /** + * Compare two value base on direction given + * The default delta is PHP_FLOAT_EPSILON + * + * @param float $value + * @param string $compare + * @param float $limit + * @param float $epsilon [default=PHP_FLOAT_EPSILON] + * @return bool True on smaller/large or equal + */ + public static function compareWithEpsilon( + float $value, + string $compare, + float $limit, + float $epsilon = PHP_FLOAT_EPSILON + ): bool { + switch ($compare) { + case '<': + if ($value < ($limit - $epsilon)) { + return true; + } + break; + case '<=': + if ($value <= ($limit - $epsilon)) { + return true; + } + break; + case '==': + return self::equalWithEpsilon($value, $limit, $epsilon); + case '>': + if ($value > ($limit + $epsilon)) { + return true; + } + break; + case '>=': + if ($value >= ($limit + $epsilon)) { + return true; + } + break; + } + return false; + } + + /** + * This function is directly inspired by the multiplyMatrices() function in color.js + * form Lea Verou and Chris Lilley. + * (see https://github.com/LeaVerou/color.js/blob/main/src/multiply-matrices.js) + * From: + * https://github.com/matthieumastadenis/couleur/blob/3842cf51c9517e77afaa0a36ec78643a0c258e0b/src/utils/utils.php#L507 + * + * It returns an array which is the product of the two number matrices passed as parameters. + * + * NOTE: + * if the right side (B matrix) has a missing row, this row will be fillwed with 0 instead of + * throwing an error: + * A: + * [ + * [1, 2, 3], + * [4, 5, 6], + * ] + * B: + * [ + * [7, 8, 9], + * [10, 11, 12], + * ] + * The B will get a third row with [0, 0, 0] added to make the multiplication work as it will be + * rewritten as + * B-rewrite: + * [ + * [7, 10, 0], + * [8, 11, 12], + * [0, 0, 0] <- automatically added + * ] + * + * @param array> $a m x n matrice + * @param array> $b n x p matrice + * + * @return array> m x p product + */ + public static function multiplyMatrices(array $a, array $b): array + { + $m = count($a); + + if (!is_array($a[0] ?? null)) { + // $a is vector, convert to [[a, b, c, ...]] + $a = [$a]; + } + + if (!is_array($b[0])) { + // $b is vector, convert to [[a], [b], [c], ...]] + $b = array_map( + callback: fn ($v) => [ $v ], + array: $b, + ); + } + + $p = count($b[0]); + + // transpose $b: + // so that we can multiply row by row + $bCols = array_map( + callback: fn ($k) => array_map( + (fn ($i) => is_array($i) ? $i[$k] : 0), + $b, + ), + array: array_keys($b[0]), + ); + + $product = array_map( + callback: fn ($row) => array_map( + callback: fn ($col) => is_array($row) ? + array_reduce( + array: $row, + callback: fn ($a, $v, $i = null) => $a + $v * ( + // if last entry missing for full copy add a 0 to it + $col[$i ?? array_search($v, $row, true)] ?? 0 /** @phpstan-ignore-line */ + ), + initial: 0, + ) : + array_reduce( + array: $col, + callback: fn ($a, $v) => $a + $v * $row, + initial: 0, + ), + array: $bCols, + ), + array: $a, + ); + + if ($m === 1) { + // Avoid [[a, b, c, ...]]: + return $product[0]; + } + + if ($p === 1) { + // Avoid [[a], [b], [c], ...]]: + return array_map( + callback: fn ($v) => $v[0] ?? 0, + array: $product, + ); + } + + return $product; + } } // __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/test/configs/config.master.php b/www/vendor/egrajp/corelibs-composer-all/test/configs/config.master.php index 355ab937..2bc50016 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/configs/config.master.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/configs/config.master.php @@ -100,27 +100,6 @@ define('DEFAULT_ACL_LEVEL', 80); /************* LOGOUT ********************/ // logout target define('LOGOUT_TARGET', ''); -// password change allowed -define('PASSWORD_CHANGE', false); -define('PASSWORD_FORGOT', false); -// min/max password length -define('PASSWORD_MIN_LENGTH', 9); -define('PASSWORD_MAX_LENGTH', 255); -// defines allowed special characters -define('PASSWORD_SPECIAL_RANGE', '@$!%*?&'); -// password must have upper case, lower case, number, special -// comment out for not mandatory -define('PASSWORD_LOWER', '(?=.*[a-z])'); -define('PASSWORD_UPPER', '(?=.*[A-Z])'); -define('PASSWORD_NUMBER', '(?=.*\d)'); -define('PASSWORD_SPECIAL', "(?=.*[" . PASSWORD_SPECIAL_RANGE . "])"); -// define full regex -define('PASSWORD_REGEX', "/^" - . (defined('PASSWORD_LOWER') ? PASSWORD_LOWER : '') - . (defined('PASSWORD_UPPER') ? PASSWORD_UPPER : '') - . (defined('PASSWORD_NUMBER') ? PASSWORD_NUMBER : '') - . (defined('PASSWORD_SPECIAL') ? PASSWORD_SPECIAL : '') - . "[A-Za-z\d" . PASSWORD_SPECIAL_RANGE . "]{" . PASSWORD_MIN_LENGTH . "," . PASSWORD_MAX_LENGTH . "}$/"); /************* AJAX / ACCESS *************/ // ajax request type @@ -161,13 +140,6 @@ define('DEFAULT_LOCALE', 'en_US.UTF-8'); // default web page encoding setting define('DEFAULT_ENCODING', 'UTF-8'); -/************* LOGGING *******************/ -// below two can be defined here, but they should be -// defined in either the header file or the file itself -// as $LOG_FILE_ID which takes presence over LOG_FILE_ID -// see Basic class constructor -define('LOG_FILE_ID', BASE_NAME); - /************* QUEUE TABLE *************/ // if we have a dev/live system // set_live is a per page/per item @@ -291,22 +263,4 @@ if (file_exists(BASE . CONFIGS . 'config.other.php')) { require BASE . CONFIGS . 'config.other.php'; } -/************* DEBUG *******************/ -// turn off debug if debug flag is OFF -if (defined('DEBUG') && DEBUG == false) { - $ECHO_ALL = false; - $DEBUG_ALL = false; - $PRINT_ALL = false; - $DB_DEBUG = false; - $ENABLE_ERROR_HANDLING = false; - $DEBUG_ALL_OVERRIDE = false; -} else { - $ECHO_ALL = false; - $DEBUG_ALL = true; - $PRINT_ALL = true; - $DB_DEBUG = true; - $ENABLE_ERROR_HANDLING = false; - $DEBUG_ALL_OVERRIDE = false; -} - // __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/test/configs/config.php b/www/vendor/egrajp/corelibs-composer-all/test/configs/config.php index 93e07ea2..bd0ee6ed 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/configs/config.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/configs/config.php @@ -53,19 +53,6 @@ for ( \gullevek\dotEnv\DotEnv::readEnvFile( $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH ); - // find trigger name "admin/" or "frontend/" in the getcwd() folder - $folder = ''; - foreach (['admin', 'frontend'] as $_folder) { - if (strstr(getcwd() ?: '', DIRECTORY_SEPARATOR . $_folder)) { - $folder = $_folder; - break; - } - } - // if content path is empty, fallback is default - if (empty($folder)) { - $folder = 'default'; - } - define('CONTENT_PATH', $folder . DIRECTORY_SEPARATOR); // load master config file that loads all other config files require $__DIR__PATH . $CONFIG_PATH_PREFIX . CONFIG_PATH . 'config.master.php'; break; diff --git a/www/vendor/egrajp/corelibs-composer-all/test/index.php b/www/vendor/egrajp/corelibs-composer-all/test/index.php index b4943245..05890900 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/index.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/index.php @@ -4,4 +4,7 @@ require "../vendor/autoload.php"; print "Bytes: " . CoreLibs\Convert\Byte::humanReadableByteFormat(123414) . "
"; +$curl = new CoreLibs\UrlRequests\Curl(); +print "Config: " . print_r($curl->getConfig(), true) . "
"; + // __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertColorsTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertColorsTest.php index aecd3f09..5d730055 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertColorsTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertColorsTest.php @@ -9,7 +9,7 @@ use PHPUnit\Framework\TestCase; /** * Test class for Convert\Colors * @coversDefaultClass \CoreLibs\Convert\Colors - * @testdox \CoreLibs\Convert\Colors method tests + * @testdox \CoreLibs\Convert\Colors legacy method tests */ final class CoreLibsConvertColorsTest extends TestCase { @@ -21,7 +21,7 @@ final class CoreLibsConvertColorsTest extends TestCase * * @return array */ - public function rgb2hexColorProvider(): array + public function providerRgb2hexColor(): array { return [ 'color' => [ @@ -88,7 +88,7 @@ final class CoreLibsConvertColorsTest extends TestCase * * @return array */ - public function hex2rgbColorProvider(): array + public function providerHex2rgbColor(): array { return [ 'color' => [ @@ -215,7 +215,7 @@ final class CoreLibsConvertColorsTest extends TestCase * * @return array */ - public function rgb2hsbColorProvider(): array + public function providerRgb2hsbColor(): array { $list = []; foreach ($this->rgb2hslAndhsbList() as $name => $values) { @@ -234,7 +234,7 @@ final class CoreLibsConvertColorsTest extends TestCase * * @return array */ - public function hsb2rgbColorProvider(): array + public function providerHsb2rgbColor(): array { $list = []; foreach ($this->rgb2hslAndhsbList() as $name => $values) { @@ -253,7 +253,7 @@ final class CoreLibsConvertColorsTest extends TestCase * * @return array */ - public function rgb2hslColorProvider(): array + public function providerRgb2hslColor(): array { $list = []; foreach ($this->rgb2hslAndhsbList() as $name => $values) { @@ -272,7 +272,7 @@ final class CoreLibsConvertColorsTest extends TestCase * * @return array */ - public function hsl2rgbColorProvider(): array + public function providerHsl2rgbColor(): array { $list = []; foreach ($this->rgb2hslAndhsbList() as $name => $values) { @@ -291,7 +291,7 @@ final class CoreLibsConvertColorsTest extends TestCase * TODO: add cross convert check * * @covers ::rgb2hex - * @dataProvider rgb2hexColorProvider + * @dataProvider providerRgb2hexColor * @testdox rgb2hex $input_r,$input_g,$input_b will be $expected [$_dataName] * * @param int $input_r @@ -342,7 +342,7 @@ final class CoreLibsConvertColorsTest extends TestCase * Undocumented function * * @covers ::hex2rgb - * @dataProvider hex2rgbColorProvider + * @dataProvider providerHex2rgbColor * @testdox hex2rgb $input will be $expected, $expected_str str[,], $expected_str_sep str[$separator] [$_dataName] * * @param string $input @@ -385,7 +385,7 @@ final class CoreLibsConvertColorsTest extends TestCase * Undocumented function * * @covers ::rgb2hsb - * @dataProvider rgb2hsbColorProvider + * @dataProvider providerRgb2hsbColor * @testdox rgb2hsb $input_r,$input_g,$input_b will be $expected [$_dataName] * * @param integer $input_r @@ -409,7 +409,7 @@ final class CoreLibsConvertColorsTest extends TestCase * Undocumented function * * @covers ::hsb2rgb - * @dataProvider hsb2rgbColorProvider + * @dataProvider providerHsb2rgbColor * @testdox hsb2rgb $input_h,$input_s,$input_b will be $expected [$_dataName] * * @param float $input_h @@ -434,7 +434,7 @@ final class CoreLibsConvertColorsTest extends TestCase * Undocumented function * * @covers ::rgb2hsl - * @dataProvider rgb2hslColorProvider + * @dataProvider providerRgb2hslColor * @testdox rgb2hsl $input_r,$input_g,$input_b will be $expected [$_dataName] * * @param integer $input_r @@ -458,7 +458,7 @@ final class CoreLibsConvertColorsTest extends TestCase * Undocumented function * * @covers ::hsl2rgb - * @dataProvider hsl2rgbColorProvider + * @dataProvider providerHsl2rgbColor * @testdox hsl2rgb $input_h,$input_s,$input_l will be $expected [$_dataName] * * @param integer|float $input_h diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertMathTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertMathTest.php index 9a97e37e..6441ca79 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertMathTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/Convert/CoreLibsConvertMathTest.php @@ -18,7 +18,7 @@ final class CoreLibsConvertMathTest extends TestCase * * @return array */ - public function fceilProvider(): array + public function providerFceil(): array { return [ '5.5 must be 6' => [5.5, 6], @@ -31,7 +31,7 @@ final class CoreLibsConvertMathTest extends TestCase * Undocumented function * * @covers ::fceil - * @dataProvider fceilProvider + * @dataProvider providerFceil * @testdox fceil: Input $input must be $expected * * @param float $input @@ -51,7 +51,7 @@ final class CoreLibsConvertMathTest extends TestCase * * @return array */ - public function floorProvider(): array + public function providerFloor(): array { return [ '5123456 with -3 must be 5123000' => [5123456, -3, 5123000], @@ -63,7 +63,7 @@ final class CoreLibsConvertMathTest extends TestCase * Undocumented function * * @covers ::floorp - * @dataProvider floorProvider + * @dataProvider providerFloor * @testdox floor: Input $input with cutoff $cutoff must be $expected * * @param int $input @@ -84,7 +84,7 @@ final class CoreLibsConvertMathTest extends TestCase * * @return array */ - public function initNumericProvider(): array + public function providerInitNumeric(): array { return [ '5 must be 5' => [5, 5, 'int'], @@ -98,7 +98,7 @@ final class CoreLibsConvertMathTest extends TestCase * Undocumented function * * @covers ::initNumeric - * @dataProvider initNumericProvider + * @dataProvider providerInitNumeric * @testdox initNumeric: Input $info $input must match $expected [$_dataName] * * @param int|float|string $input @@ -113,6 +113,358 @@ final class CoreLibsConvertMathTest extends TestCase \CoreLibs\Convert\Math::initNumeric($input) ); } + + /** + * Undocumented function + * + * @return array + */ + public function providerCbrt(): array + { + return [ + 'cube root of 2' => [2, 1.25992, 5], + 'cube root of 3' => [3, 1.44225, 5], + 'cube root of -1' => [-1, 'NAN', 0], + ]; + } + + /** + * Undocumented function + * + * @covers ::cbrt + * @dataProvider providerCbrt + * @testdox initNumeric: Input $input must match $expected [$_dataName] + * + * @param float|int $number + * @param float $expected + * @param int $round_to + * @return void + */ + public function testCbrt(float|int $number, float|string $expected, int $round_to): void + { + $this->assertEquals( + $expected, + round(\CoreLibs\Convert\Math::cbrt($number), $round_to) + ); + } + + /** + * Undocumented function + * + * @return array + */ + public function providerMultiplyMatrices(): array + { + return [ + '[3] x [3] => [3x1]' => [ + [1, 2, 3], + [1, 2, 3], + [14] + ], + '[3] x [3x1]' => [ + [1, 2, 3], + [[1], [2], [3]], + [14] + ], + '[3] x [3x1]' => [ + [1, 2, 3], + [[1], [2], [3]], + [14] + ], + '[1x3L] x [3x1]' => [ + [[1, 2, 3]], + [[1], [2], [3]], + [14] + ], + '[1x3] x [3x1]' => [ + [[1], [2], [3]], + [[1], [2], [3]], + [1, 2, 3] + ], + '[2x3] x [3] => [3x1]' => [ + [ + [1, 2, 3], + [1, 2, 3] + ], + [1, 2, 3], + [ + 14, + 14 + ] + ], + '[2x3] x [3x1]' => [ + [ + [1, 2, 3], + [1, 2, 3] + ], + [[1], [2], [3]], + [ + 14, + 14 + ] + ], + '[2x3] x [2x3] => [3x3]' => [ + [ + [1, 2, 3], + [1, 2, 3], + ], + [ + [1, 2, 3], + [1, 2, 3], + ], + [ + [3, 6, 9], + [3, 6, 9] + ] + ], + '[2x3] x [3x3]' => [ + [ + [1, 2, 3], + [1, 2, 3], + ], + [ + [1, 2, 3], + [1, 2, 3], + [0, 0, 0], + ], + [ + [3, 6, 9], + [3, 6, 9] + ] + ], + '[2x3] x [3x2]' => [ + 'a' => [ + [1, 2, 3], + [1, 2, 3], + ], + 'b' => [ + [1, 1], + [2, 2], + [3, 3], + ], + 'prod' => [ + [14, 14], + [14, 14], + ] + ], + '[3x3] x [3] => [1x3]' => [ + [ + [1, 2, 3], + [1, 2, 3], + [1, 2, 3], + ], + [1, 2, 3], + [ + 14, + 14, + 14 + ] + ], + '[3x3] x [2x3] => [3x3]' => [ + [ + [1, 2, 3], + [1, 2, 3], + [1, 2, 3], + ], + [ + [1, 2, 3], + [1, 2, 3], + ], + [ + [3, 6, 9], + [3, 6, 9], + [3, 6, 9], + ] + ], + '[3x3] x [3x3]' => [ + [ + [1, 2, 3], + [1, 2, 3], + [1, 2, 3], + ], + [ + [1, 2, 3], + [1, 2, 3], + // [0, 0, 0], + ], + [ + [3, 6, 9], + [3, 6, 9], + [3, 6, 9], + ] + ], + '[3] x [3x3]' => [ + [1, 2, 3], + [ + [1, 2, 3], + [1, 2, 3], + [1, 2, 3], + ], + [ + [6, 12, 18], + ] + ], + '[2x3] x [3x3]' => [ + [ + [1, 2, 3], + [1, 2, 3], + ], + [ + [1, 2, 3], + [1, 2, 3], + [1, 2, 3], + ], + [ + [6, 12, 18], + [6, 12, 18], + ] + ], + ]; + } + + /** + * Undocumented function + * + * @covers ::multiplyMatrices + * @dataProvider providerMultiplyMatrices + * @testdox initNumeric: Input $input_a x $input_b must match $expected [$_dataName] + * + * @param array $input_a + * @param array $input_b + * @param array $expected + * @return void + */ + public function testMultiplyMatrices(array $input_a, array $input_b, array $expected): void + { + $this->assertEquals( + $expected, + \CoreLibs\Convert\Math::multiplyMatrices($input_a, $input_b) + ); + } + + /** + * Undocumented function + * + * @return array + */ + public function providerEqualWithEpsilon(): array + { + return [ + 'equal' => [ + 'a' => 0.000000000000000222, + 'b' => 0.000000000000000222, + 'epsilon' => PHP_FLOAT_EPSILON, + 'equal' => true, + ], + 'almost equal' => [ + 'a' => 0.000000000000000222, + 'b' => 0.000000000000000232, + 'epsilon' => PHP_FLOAT_EPSILON, + 'equal' => true, + ], + 'not equal' => [ + 'a' => 0.000000000000000222, + 'b' => 0.000000000000004222, + 'epsilon' => PHP_FLOAT_EPSILON, + 'equal' => false, + ], + 'equal, different epsilon' => [ + 'a' => 0.000000000000000222, + 'b' => 0.000000000000004222, + 'epsilon' => 0.0001, + 'equal' => true, + ], + 'not equal, different epsilon' => [ + 'a' => 0.0001, + 'b' => 0.0002, + 'epsilon' => 0.0001, + 'equal' => false, + ] + ]; + } + + /** + * Undocumented function + * + * @covers ::equalWithEpsilon + * @dataProvider providerEqualWithEpsilon + * @testdox equalWithEpsilon with $a and $b and Epsilon: $epsilon must be equal: $equal [$_dataName] + * + * @return void + */ + public function testEqualWithEpsilon(float $a, float $b, float $epsilon, bool $equal): void + { + $this->assertEquals( + $equal, + \CoreLibs\Convert\Math::equalWithEpsilon($a, $b, $epsilon) + ); + } + + /** + * Undocumented function + * + * @return array + */ + public function providerCompareWithEpsilon(): array + { + return [ + 'smaller, true' => [ + 'value' => 0.0001, + 'compare' => '<', + 'limit' => 0.0002, + 'epsilon' => 0.00001, + 'match' => true, + ], + 'smaller, false' => [ + 'value' => 0.0001, + 'compare' => '<', + 'limit' => 0.0001, + 'epsilon' => 0.00001, + 'match' => false, + ], + 'bigger, true' => [ + 'value' => 0.0002, + 'compare' => '>', + 'limit' => 0.0001, + 'epsilon' => 0.00001, + 'match' => true, + ], + 'bigger, false' => [ + 'value' => 0.0001, + 'compare' => '>', + 'limit' => 0.0001, + 'epsilon' => 0.00001, + 'match' => false, + ], + ]; + } + + /** + * Undocumented function + * + * @covers ::compareWithEpsilon + * @dataProvider providerCompareWithEpsilon + * @testdox compareWithEpsilon $value $compare $limit with $epsilon must match: $match [$_dataName] + * + * @param float $value + * @param string $compare + * @param float $limit + * @param float $epslion + * @param bool $match + * @return void + */ + public function testCompareWithEpsilon( + float $value, + string $compare, + float $limit, + float $epsilon, + bool $match + ): void { + $this->assertEquals( + $match, + \CoreLibs\Convert\Math::compareWithEpsilon($value, $compare, $limit, $epsilon) + ); + } } // __END__ diff --git a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/DB/CoreLibsDBExtendedArrayIOTest.php b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/DB/CoreLibsDBExtendedArrayIOTest.php index f5204ed5..1e50e92d 100644 --- a/www/vendor/egrajp/corelibs-composer-all/test/phpunit/DB/CoreLibsDBExtendedArrayIOTest.php +++ b/www/vendor/egrajp/corelibs-composer-all/test/phpunit/DB/CoreLibsDBExtendedArrayIOTest.php @@ -10,7 +10,6 @@ use PHPUnit\Framework\TestCase; * Test class for DB\Extended\ArrayIO * This will only test the PgSQL parts * @coversDefaultClass \CoreLibs\DB\Extended\ArrayIO - * @coversDefaultClass \CoreLibs\DB\Extended\ArrayIO * @testdox \CoreLibs\Extended\ArrayIO method tests for extended DB interface */ final class CoreLibsDBExtendedArrayIOTest extends TestCase