This is 1.0

This commit is contained in:
Bernd Bestel
2017-04-20 17:10:21 +02:00
parent e38c24f9ed
commit c4a22c18f7
21 changed files with 594 additions and 146 deletions

View File

@@ -14,4 +14,36 @@ class GrocyPhpHelper
return null;
}
public static function FindAllObjectsInArrayByPropertyValue($array, $propertyName, $propertyValue, $operator = '==')
{
$returnArray = array();
foreach($array as $object)
{
switch($operator)
{
case '==':
if($object->{$propertyName} == $propertyValue)
{
$returnArray[] = $object;
}
break;
case '>':
if($object->{$propertyName} > $propertyValue)
{
$returnArray[] = $object;
}
break;
case '<':
if($object->{$propertyName} < $propertyValue)
{
$returnArray[] = $object;
}
break;
}
}
return $returnArray;
}
}