[LIB][Util] Remove Functional::arity as it got merged upstream as Functional\ary
This commit is contained in:
parent
d6cd52cede
commit
fb53700be2
@ -31,7 +31,6 @@
|
|||||||
namespace App\Util;
|
namespace App\Util;
|
||||||
|
|
||||||
use const DIRECTORY_SEPARATOR;
|
use const DIRECTORY_SEPARATOR;
|
||||||
use Functional;
|
|
||||||
use Functional as F;
|
use Functional as F;
|
||||||
use InvalidArgumentException;
|
use InvalidArgumentException;
|
||||||
use Symfony\Component\Config\Definition\Exception\Exception;
|
use Symfony\Component\Config\Definition\Exception\Exception;
|
||||||
@ -121,24 +120,14 @@ abstract class Formatting
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $str
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function camelCaseToSnakeCase(string $str): string
|
public static function camelCaseToSnakeCase(string $str): string
|
||||||
{
|
{
|
||||||
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $str));
|
return strtolower(preg_replace('/([a-z])([A-Z])/', '$1_$2', $str));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @param string $str
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
public static function snakeCaseToCamelCase(string $str): string
|
public static function snakeCaseToCamelCase(string $str): string
|
||||||
{
|
{
|
||||||
return implode('', F\map(preg_split('/[\b_]/', $str), Functional::arity('ucfirst', 1)));
|
return implode('', F\map(preg_split('/[\b_]/', $str), F\ary('ucfirst', 1)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -157,7 +146,7 @@ abstract class Formatting
|
|||||||
} elseif (is_array($in)) {
|
} elseif (is_array($in)) {
|
||||||
$indent = str_repeat(' ', $count * $level);
|
$indent = str_repeat(' ', $count * $level);
|
||||||
return implode("\n", F\map(F\select($in,
|
return implode("\n", F\map(F\select($in,
|
||||||
Functional::arity(function ($s) {
|
F\ary(function ($s) {
|
||||||
return $s != '';
|
return $s != '';
|
||||||
}, 1)),
|
}, 1)),
|
||||||
function ($val) use ($indent) {
|
function ($val) use ($indent) {
|
||||||
|
@ -30,26 +30,6 @@
|
|||||||
|
|
||||||
namespace App\Util;
|
namespace App\Util;
|
||||||
|
|
||||||
use Functional as F;
|
|
||||||
|
|
||||||
abstract class Functional
|
abstract class Functional
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Call $func with only abs($count) arguments, taken either from the
|
|
||||||
* left or right depending on the sign
|
|
||||||
*
|
|
||||||
* @param callable $func
|
|
||||||
* @param int $count
|
|
||||||
*
|
|
||||||
* @return callable
|
|
||||||
*/
|
|
||||||
public static function arity(callable $func, int $count): callable
|
|
||||||
{
|
|
||||||
return function (...$args) use ($func, $count) {
|
|
||||||
if ($count > 0) {
|
|
||||||
return call_user_func_array($func, F\take_left($args, $count));
|
|
||||||
}
|
|
||||||
return call_user_func_array($func, F\take_right($args, -$count));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user