The method msort uses an else expression. Else clauses are basically not necessary and you can simplify the code by not using them. Open
} else {
if (isset($item[$id]) && strip_tags($item[$id]) > strip_tags($array[$lowest_id][$id])) {
$lowest_id = $index;
}
}
- Read upRead up
- Exclude checks
ElseExpression
Since: 1.4.0
An if expression with an else branch is basically not necessary. You can rewrite the conditions in a way that the else clause is not necessary and the code becomes simpler to read. To achieve this, use early return statements, though you may need to split the code it several smaller methods. For very simple assignments you could also use the ternary operations.
Example
class Foo
{
public function bar($flag)
{
if ($flag) {
// one branch
} else {
// another branch
}
}
}
Source https://phpmd.org/rules/cleancode.html#elseexpression
Variable "lowest_id" is not in valid camel caps format Open
if (isset($item[$id]) && strip_tags($item[$id]) > strip_tags($array[$lowest_id][$id])) {
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
$lowest_id = $index;
- Exclude checks
Variable "temp_array" is not in valid camel caps format Open
return $temp_array;
- Exclude checks
Consider putting global function "utf8_sort" in a static class Open
function utf8_sort($array)
- Exclude checks
Variable "locale_list" is not in valid camel caps format Open
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Exclude checks
Variable "try_sort" is not in valid camel caps format Open
$try_sort = true;
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
$lowest_id = 0;
- Exclude checks
Variable "temp_array" is not in valid camel caps format Open
$temp_array[] = $array[$lowest_id];
- Exclude checks
Variable "my_local" is not in valid camel caps format Open
$my_local = setlocale(LC_COLLATE, $locale);
- Exclude checks
Consider putting global function "array_unique_dimensional" in a static class Open
function array_unique_dimensional($array)
- Exclude checks
Variable "old_locale" is not in valid camel caps format Open
$old_locale = setlocale(LC_ALL, 0);
- Exclude checks
Variable "old_locale" is not in valid camel caps format Open
setlocale(LC_COLLATE, $old_locale);
- Exclude checks
Missing parameter name Open
* @param $array
- Exclude checks
Missing parameter name Open
* @param array unsorted multidimensional array
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
if (strip_tags($item[$id]) < strip_tags($array[$lowest_id][$id])) {
- Exclude checks
Consider putting global function "array_flatten" in a static class Open
function array_flatten(array $array)
- Exclude checks
Consider putting global function "msort" in a static class Open
function msort($array, $id = 'id', $order = 'desc')
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
$temp_array[] = $array[$lowest_id];
- Exclude checks
Variable "try_sort" is not in valid camel caps format Open
if ($try_sort) {
- Exclude checks
Consider putting global function "array_to_string" in a static class Open
function array_to_string($array, $separator = ',')
- Exclude checks
Missing parameter name Open
* @param $array
- Exclude checks
Missing parameter name Open
* @param string key to be sorted
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
array_slice($array, 0, $lowest_id),
- Exclude checks
Variable "try_sort" is not in valid camel caps format Open
$try_sort = false;
- Exclude checks
Variable "my_local" is not in valid camel caps format Open
if ($my_local) {
- Exclude checks
Variable "locale_list" is not in valid camel caps format Open
foreach ($locale_list as $locale) {
- Exclude checks
Consider putting global function "shuffle_assoc" in a static class Open
function shuffle_assoc(&$array)
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
array_slice($array, $lowest_id + 1)
- Exclude checks
Variable "temp_array" is not in valid camel caps format Open
$temp_array = [];
- Exclude checks
Variable "lowest_id" is not in valid camel caps format Open
$lowest_id = $index;
- Exclude checks
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $try_sort is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $temp_array is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $locale_list is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $my_local is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $old_locale is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $temp_array is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $try_sort is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $try_sort is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $temp_array is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $my_local is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $locale_list is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $old_locale is not named in camelCase. Open
function utf8_sort($array)
{
$old_locale = setlocale(LC_ALL, 0);
$code = api_get_language_isocode();
$locale_list = [$code.'.utf8', 'en.utf8', 'en_US.utf8', 'en_GB.utf8'];
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}
Source
The variable $lowest_id is not named in camelCase. Open
function msort($array, $id = 'id', $order = 'desc')
{
if (empty($array)) {
return $array;
}
- Read upRead up
- Exclude checks
CamelCaseVariableName
Since: 0.2
It is considered best practice to use the camelCase notation to name variables.
Example
class ClassName {
public function doSomething() {
$data_module = new DataModule();
}
}