From a392235e23c3b8af1d0eba4dbac18b18de826a1c Mon Sep 17 00:00:00 2001 From: Julius Härtl Date: Sun, 28 Aug 2022 20:54:21 +0200 Subject: Cleanup MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Julius Härtl --- core/Controller/ReferenceApiController.php | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'core/Controller/ReferenceApiController.php') diff --git a/core/Controller/ReferenceApiController.php b/core/Controller/ReferenceApiController.php index d9af5520cfc..3e94bf34c25 100644 --- a/core/Controller/ReferenceApiController.php +++ b/core/Controller/ReferenceApiController.php @@ -25,23 +25,19 @@ declare(strict_types=1); namespace OC\Core\Controller; use OCP\AppFramework\Http\DataResponse; -use OC\Collaboration\Reference\ReferenceManager; +use OCP\Collaboration\Reference\IReferenceManager; use OCP\IRequest; class ReferenceApiController extends \OCP\AppFramework\OCSController { - private ReferenceManager $referenceManager; + private IReferenceManager $referenceManager; - public function __construct($appName, IRequest $request, ReferenceManager $referenceManager) { + public function __construct(string $appName, IRequest $request, IReferenceManager $referenceManager) { parent::__construct($appName, $request); $this->referenceManager = $referenceManager; } /** * @NoAdminRequired - * - * @param string $text - * @param bool $resolve - * @return DataResponse */ public function extract(string $text, bool $resolve = false, int $limit = 1): DataResponse { $references = $this->referenceManager->extractReferences($text); @@ -63,16 +59,17 @@ class ReferenceApiController extends \OCP\AppFramework\OCSController { /** * @NoAdminRequired * - * @param array $references - * @return DataResponse + * @param string[] $references */ public function resolve(array $references, int $limit = 1): DataResponse { $result = []; $index = 0; foreach ($references as $reference) { - if ($index++ < $limit) { - $result[$reference] = $this->referenceManager->resolveReference($reference); + if ($index++ >= $limit) { + break; } + + $result[$reference] = $this->referenceManager->resolveReference($reference); } return new DataResponse([ -- cgit v1.2.3