Skip to content
GitLab
Explore
Projects
Groups
Topics
Snippets
Projects
Groups
Topics
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
fusiondirectory
fusiondirectory-orchestrator
Commits
1e21ea1f
Commit
1e21ea1f
authored
1 month ago
by
Oana-Eliza Alexa
Browse files
Options
Download
Patches
Plain Diff
fix indent
parent
db7c0f4f
80-redesign-notifications-class
1 merge request
!76
Draft: Resolve "Redesign notifications class"
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
library/Utils.php
+69
-69
library/Utils.php
with
69 additions
and
69 deletions
+69
-69
library/Utils.php
+
69
−
69
View file @
1e21ea1f
...
@@ -2,82 +2,82 @@
...
@@ -2,82 +2,82 @@
class
Utils
class
Utils
{
{
private
function
__construct
()
{}
private
function
__construct
()
{}
/**
/**
* @param array $array
* @param array $array
* @return array
* @return array
* Note : Recursively filters out empty values and arrays at any depth.
* Note : Recursively filters out empty values and arrays at any depth.
*/
*/
public
static
function
recursiveArrayFilter
(
array
$array
):
array
public
static
function
recursiveArrayFilter
(
array
$array
):
array
{
{
// First filter the array for non-empty elements
// First filter the array for non-empty elements
$filtered
=
array_filter
(
$array
,
function
(
$item
)
{
$filtered
=
array_filter
(
$array
,
function
(
$item
)
{
if
(
is_array
(
$item
))
{
if
(
is_array
(
$item
))
{
// Recursively filter the sub-array
// Recursively filter the sub-array
$item
=
$this
->
recursiveArrayFilter
(
$item
);
$item
=
$this
->
recursiveArrayFilter
(
$item
);
// Only retain non-empty arrays
// Only retain non-empty arrays
return
!
empty
(
$item
);
return
!
empty
(
$item
);
}
else
{
}
else
{
// Retain non-empty scalar values
// Retain non-empty scalar values
return
!
empty
(
$item
);
return
!
empty
(
$item
);
}
}
});
});
return
$filtered
;
return
$filtered
;
}
}
/**
/**
* Find matching keys between 2 lists.
* Find matching keys between 2 lists.
*
*
* @param array|null $elements
* @param array|null $elements
* @param array $keys
* @param array $keys
* @return array
* @return array
*/
*/
public
static
function
findMatchingKeys
(
?array
$elements
,
array
$keys
):
array
public
static
function
findMatchingKeys
(
?array
$elements
,
array
$keys
):
array
{
{
$matching
=
[];
$matching
=
[];
if
(
!
empty
(
$elements
))
{
if
(
!
empty
(
$elements
))
{
foreach
(
$elements
as
$element
)
{
foreach
(
$elements
as
$element
)
{
foreach
(
$keys
as
$key
)
{
foreach
(
$keys
as
$key
)
{
if
(
!
empty
(
$element
)
&&
array_key_exists
(
$key
,
$element
))
{
if
(
!
empty
(
$element
)
&&
array_key_exists
(
$key
,
$element
))
{
$matching
[]
=
$key
;
$matching
[]
=
$key
;
}
}
}
}
}
}
}
return
$matching
;
}
}
/**
return
$matching
;
* @param $array
}
* @return array
* Note : simply return all values of a multi-dimensional array.
*/
public
static
function
getArrayValuesRecursive
(
$array
)
{
$values
=
[];
foreach
(
$array
as
$value
)
{
if
(
is_array
(
$value
))
{
// If value is an array, merge its values recursively
$values
=
array_merge
(
$values
,
self
::
getArrayValuesRecursive
(
$value
));
}
else
{
// If value is not an array, add it to the result
$values
[]
=
$value
;
}
}
return
$values
;
}
/**
/**
* @param string $text
* @param $array
* @return string
* @return array
* Note : This come from jwtToken, as it is completely private - it is cloned here for now.
* Note : simply return all values of a multi-dimensional array.
*/
*/
public
static
function
base64urlEncode
(
string
$text
):
string
public
static
function
getArrayValuesRecursive
(
$array
)
{
{
return
str_replace
([
"+"
,
"/"
,
"="
],
[
"A"
,
"B"
,
""
],
base64_encode
(
$text
));
$values
=
[];
foreach
(
$array
as
$value
)
{
if
(
is_array
(
$value
))
{
// If value is an array, merge its values recursively
$values
=
array_merge
(
$values
,
self
::
getArrayValuesRecursive
(
$value
));
}
else
{
// If value is not an array, add it to the result
$values
[]
=
$value
;
}
}
}
return
$values
;
}
/**
* @param string $text
* @return string
* Note : This come from jwtToken, as it is completely private - it is cloned here for now.
*/
public
static
function
base64urlEncode
(
string
$text
):
string
{
return
str_replace
([
"+"
,
"/"
,
"="
],
[
"A"
,
"B"
,
""
],
base64_encode
(
$text
));
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment
Menu
Explore
Projects
Groups
Topics
Snippets