1. Go to this page and download the library: Download needle-project/common library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
NeedleProject\Common\Convertor\CompoundWordConvertor;
echo CompoundWordConvertor::convertToCamelCase("fooBar");
// will output "foobar", not fooBar
echo CompoundWordConvertor::convertToPascalCase("FooBar");
// will output "Foobar", not FooBar
echo CompoundWordConvertor::convertToSnakeCase("FOO BAR");
// will output "f_o_o_b_a_r", not "foo_bar"
NeedleProject\Common\Helper\ArrayHelper;
$searchFor = ['level1', 'level2', 'level3'];
$searchIn = [
'level1' => [
'level2' => [
'level3' => 'A value'
]
]
];
$helper = new ArrayHelper();
if ($helper->hasKeysInDepth($searchIn, $searchFor)) {
echo $helper->getValueFromDepth($searchIn, $searchFor);
// A value
}
NeedleProject\Common\Util\ErrorToExceptionConverter;
class CustomException extends \Exception {
}
$convertor = new ErrorToExceptionConverter();
$convertor->convertErrorsToExceptions(E_ALL, CustomException::class);
try {
print(a);
} catch (\Exception $e) {
echo get_class($e) . "\n";
echo $e->getMessage();
}
// restore the previous state of error handling
$convertor->restoreErrorHandler();