Skip to content

Commit

Permalink
Update if condition to set empty []
Browse files Browse the repository at this point in the history
  • Loading branch information
PG-Momik committed Sep 16, 2024
1 parent 31662fd commit dc5758b
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/IATI/Services/ElementCompleteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -810,18 +810,20 @@ public function getFormattedResults($activity): array

foreach ($results as $result) {
$resultId = $result['id'];
$resultIndicators = $result['indicators'];

$resultReference = Arr::get($result['result'], 'reference');
$resultData[$resultId] = $result['result'];
$resultData[$resultId] = Arr::get($result, 'result', []);
$resultIndicators = Arr::get($result, 'indicators', []);

if ($resultIndicators && count($resultIndicators) === 0) {
if (count($resultIndicators) === 0) {
$resultData[$resultId] = [];
continue;
}

foreach ($resultIndicators as $index => $indicator) {
$indicatorId = $indicator['id'];
$indicatorValue = $indicator['indicator'];
$indicatorId = "$resultId.$indicatorId";
$indicatorValue = Arr::get($indicator, 'indicator', []);

if (is_array_value_empty(Arr::get($indicatorValue, 'reference'))) {
$indicatorValue['reference'] = $resultReference;
Expand All @@ -830,14 +832,14 @@ public function getFormattedResults($activity): array
}

$indicatorData[$indicatorId] = $indicatorValue;
$periods = $indicator['periods'];
$periods = Arr::get($indicator, 'periods', []);

if ($periods && count($periods) === 0) {
if (count($periods) === 0) {
continue;
}

foreach ($periods as $period) {
$periodData[] = $period['period'];
$periodData[] = Arr::get($period, 'period', []);
}
}
}
Expand Down

0 comments on commit dc5758b

Please sign in to comment.