Skip to content

Commit d06fd46

Browse files
phpcs fixed
1 parent 07a370b commit d06fd46

2 files changed

Lines changed: 65 additions & 69 deletions

File tree

src/Api/Monetization/Denormalizer/LegalEntityDenormalizer.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ public function denormalize($data, $type, $format = null, array $context = []):
6868
{
6969
if ($data->isCompany) {
7070
return parent::denormalize($data, $this->companyClass, $format, $context);
71-
} else {
72-
return parent::denormalize($data, $this->developerClass, $format, $context);
7371
}
72+
73+
return parent::denormalize($data, $this->developerClass, $format, $context);
7474
}
7575

7676
/**

src/Controller/PaginationHelperTrait.php

Lines changed: 63 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,10 @@ protected function listEntities(?PagerInterface $pager = null, array $query_para
111111

112112
if (OrganizationFeatures::isPaginationAvailable($organization)) {
113113
return $this->listEntitiesWithCps($pager, $query_params, $key_provider);
114-
} else {
115-
$this->triggerCpsSimulationNotice($pager);
116-
117-
return $this->listEntitiesWithoutCps($pager, $query_params, $key_provider);
118114
}
115+
$this->triggerCpsSimulationNotice($pager);
116+
117+
return $this->listEntitiesWithoutCps($pager, $query_params, $key_provider);
119118
}
120119

121120
/**
@@ -136,11 +135,10 @@ protected function listEntityIds(?PagerInterface $pager = null, array $query_par
136135

137136
if (OrganizationFeatures::isCpsEnabled($organization)) {
138137
return $this->listEntityIdsWithCps($pager, $query_params);
139-
} else {
140-
$this->triggerCpsSimulationNotice($pager);
141-
142-
return $this->listEntityIdsWithoutCps($pager, $query_params);
143138
}
139+
$this->triggerCpsSimulationNotice($pager);
140+
141+
return $this->listEntityIdsWithoutCps($pager, $query_params);
144142
}
145143

146144
/**
@@ -181,43 +179,42 @@ private function listEntitiesWithCps(?PagerInterface $pager = null, array $query
181179
$responseArray = reset($responseArray) ?: [];
182180

183181
return $this->responseArrayToArrayOfEntities($responseArray, $key_provider);
184-
} else {
185-
// Pass an empty pager to load all entities.
186-
$responseArray = $this->getResultsInRange($this->createPager(), $query_params);
187-
// Ignore entity type key from response, ex.: developer, apiproduct,
188-
// etc.
189-
$responseArray = reset($responseArray);
190-
if (empty($responseArray)) {
191-
return [];
192-
}
193-
$entities = $this->responseArrayToArrayOfEntities($responseArray, $key_provider);
194-
$lastEntity = end($entities);
195-
$lastId = $lastEntity->{$key_provider}();
196-
do {
197-
$tmp = $this->getResultsInRange($this->createPager(0, $lastId), $query_params);
198-
// Ignore entity type key from response, ex.: developer,
199-
// apiproduct, etc.
200-
$tmp = reset($tmp) ?: [];
201-
// Remove the first item from the list because it is the same
202-
// as the last item of $entities at this moment.
203-
// Apigee Edge response always starts with the requested entity
204-
// (startKey).
205-
array_shift($tmp);
206-
$tmpEntities = $this->responseArrayToArrayOfEntities((array) $tmp, $key_provider);
207-
208-
if (count($tmpEntities) > 0) {
209-
// The returned entity array is keyed by entity id which
210-
// is unique so we can do this.
211-
$entities += $tmpEntities;
212-
$lastEntity = end($tmpEntities);
213-
$lastId = $lastEntity->{$key_provider}();
214-
} else {
215-
$lastId = false;
216-
}
217-
} while ($lastId);
218-
219-
return $entities;
220182
}
183+
// Pass an empty pager to load all entities.
184+
$responseArray = $this->getResultsInRange($this->createPager(), $query_params);
185+
// Ignore entity type key from response, ex.: developer, apiproduct,
186+
// etc.
187+
$responseArray = reset($responseArray);
188+
if (empty($responseArray)) {
189+
return [];
190+
}
191+
$entities = $this->responseArrayToArrayOfEntities($responseArray, $key_provider);
192+
$lastEntity = end($entities);
193+
$lastId = $lastEntity->{$key_provider}();
194+
do {
195+
$tmp = $this->getResultsInRange($this->createPager(0, $lastId), $query_params);
196+
// Ignore entity type key from response, ex.: developer,
197+
// apiproduct, etc.
198+
$tmp = reset($tmp) ?: [];
199+
// Remove the first item from the list because it is the same
200+
// as the last item of $entities at this moment.
201+
// Apigee Edge response always starts with the requested entity
202+
// (startKey).
203+
array_shift($tmp);
204+
$tmpEntities = $this->responseArrayToArrayOfEntities((array) $tmp, $key_provider);
205+
206+
if (count($tmpEntities) > 0) {
207+
// The returned entity array is keyed by entity id which
208+
// is unique so we can do this.
209+
$entities += $tmpEntities;
210+
$lastEntity = end($tmpEntities);
211+
$lastId = $lastEntity->{$key_provider}();
212+
} else {
213+
$lastId = false;
214+
}
215+
} while ($lastId);
216+
217+
return $entities;
221218
}
222219

223220
/**
@@ -322,30 +319,29 @@ private function listEntityIdsWithCps(?PagerInterface $pager = null, array $quer
322319
$expandCompatibility = str_ends_with($this->getClient()->getEndpoint(), $baseDomain);
323320
if ($pager) {
324321
return $this->getResultsInRange($pager, $query_params, $expandCompatibility);
325-
} else {
326-
$ids = $this->getResultsInRange($this->createPager(), $query_params, $expandCompatibility);
327-
if (empty($ids)) {
328-
return [];
329-
}
330-
$lastId = end($ids);
331-
do {
332-
$tmp = $this->getResultsInRange($this->createPager(0, $lastId), $query_params, $expandCompatibility);
333-
// Remove the first item from the list because it is the same
334-
// as the current last item of $ids.
335-
// Apigee Edge response always starts with the requested entity
336-
// id (startKey).
337-
array_shift($tmp);
338-
339-
if (count($tmp) > 0) {
340-
$ids = array_merge($ids, $tmp);
341-
$lastId = end($tmp);
342-
} else {
343-
$lastId = false;
344-
}
345-
} while ($lastId);
346-
347-
return $ids;
348322
}
323+
$ids = $this->getResultsInRange($this->createPager(), $query_params, $expandCompatibility);
324+
if (empty($ids)) {
325+
return [];
326+
}
327+
$lastId = end($ids);
328+
do {
329+
$tmp = $this->getResultsInRange($this->createPager(0, $lastId), $query_params, $expandCompatibility);
330+
// Remove the first item from the list because it is the same
331+
// as the current last item of $ids.
332+
// Apigee Edge response always starts with the requested entity
333+
// id (startKey).
334+
array_shift($tmp);
335+
336+
if (count($tmp) > 0) {
337+
$ids = array_merge($ids, $tmp);
338+
$lastId = end($tmp);
339+
} else {
340+
$lastId = false;
341+
}
342+
} while ($lastId);
343+
344+
return $ids;
349345
}
350346

351347
/**

0 commit comments

Comments
 (0)