r3-v2/utils.php

79 lines
1.8 KiB
PHP
Raw Normal View History

2021-06-21 11:43:10 +02:00
<?php
2021-08-04 10:50:28 +02:00
function to_camel_case_from_uppper_underscore($string, $capitalizeFirstCharacter = true)
{
$str = str_replace(' ', '', ucwords(str_replace('_', ' ', strtolower($string))));
if (!$capitalizeFirstCharacter) {
$str[0] = strtolower($str[0]);
}
return $str;
}
function from_camel_case($input) {
preg_match_all('!([A-Z][A-Z0-9]*(?=$|[A-Z][a-z0-9])|[A-Za-z][a-z0-9]+)!', $input, $matches);
$ret = $matches[0];
foreach ($ret as &$match) {
$match = $match == strtoupper($match) ? strtolower($match) : lcfirst($match);
}
return implode('_', $ret);
}
2021-06-21 11:43:10 +02:00
if (isset($argc)) {
2021-07-01 16:39:25 +02:00
for ($i = 0; $i < $argc; $i++) {
echo "Argument #" . $i . " - " . $argv[$i] . "\n";
}
2021-06-21 11:43:10 +02:00
}
else {
2021-07-01 16:39:25 +02:00
echo "argc and argv disabled\n";
2021-06-21 11:43:10 +02:00
}
$files = [];
if ($argv[1] == 'all') {
2021-07-01 16:39:25 +02:00
$files = scandir('src/r3/', SCANDIR_SORT_DESCENDING);
$systemFiles = scandir('src/r3/r3-system', SCANDIR_SORT_DESCENDING);
2021-07-03 10:40:05 +02:00
$componentFiles = scandir('src/r3/r3-component', SCANDIR_SORT_DESCENDING);
2021-07-01 16:39:25 +02:00
$newFiles = [];
for ($i = 0; $i < sizeof($files); $i++) {
if (preg_match('/index\.js$/', $files[$i])) {
continue;
}
if (preg_match('/\.js$/', $files[$i])) {
array_push($newFiles, 'src/r3/' . $files[$i]);
}
}
2021-06-21 11:43:10 +02:00
2021-07-01 16:39:25 +02:00
for ($i = 0; $i < sizeof($systemFiles); $i++) {
2021-06-21 11:43:10 +02:00
if (preg_match('/index\.js$/', $systemFiles[$i])) {
2021-07-01 16:39:25 +02:00
continue;
2021-06-21 11:43:10 +02:00
}
2021-07-01 16:39:25 +02:00
if (preg_match('/\.js$/', $systemFiles[$i])) {
array_push($newFiles, 'src/r3/r3-system/' . $systemFiles[$i]);
2021-06-21 11:43:10 +02:00
}
2021-07-01 16:39:25 +02:00
}
2021-06-21 11:43:10 +02:00
2021-07-03 10:40:05 +02:00
for ($i = 0; $i < sizeof($componentFiles); $i++) {
if (preg_match('/index\.js$/', $componentFiles[$i])) {
continue;
}
if (preg_match('/\.js$/', $componentFiles[$i])) {
array_push($newFiles, 'src/r3/r3-component/' . $componentFiles[$i]);
}
}
2021-07-01 16:39:25 +02:00
$files = $newFiles;
2021-06-21 11:43:10 +02:00
} else {
2021-07-01 16:39:25 +02:00
$files = [$argv[1]];
2021-06-21 11:43:10 +02:00
}