diff --git a/database/migrations/create_unique_surveyhero_id_indices.php b/database/migrations/create_unique_surveyhero_id_indices.php index 9214c3f..8c9269a 100644 --- a/database/migrations/create_unique_surveyhero_id_indices.php +++ b/database/migrations/create_unique_surveyhero_id_indices.php @@ -27,7 +27,8 @@ public function up() }); Schema::table($tableNames['survey_question_responses']['name'], function (Blueprint $table) { - $table->unique(['survey_response_id', 'survey_question_id', 'survey_answer_id']); + $table->unique(['survey_response_id', 'survey_question_id', 'survey_answer_id']) + ->name('survey_question_responses_ternary_ids_idx'); //for some dbs the id name generated by laravel is too long }); } } diff --git a/src/Commands/SurveyheroMapperCommand.php b/src/Commands/SurveyheroMapperCommand.php index 869ce45..041849a 100644 --- a/src/Commands/SurveyheroMapperCommand.php +++ b/src/Commands/SurveyheroMapperCommand.php @@ -16,9 +16,6 @@ class SurveyheroMapperCommand extends Command public $description = 'Map all questions and answers linked to configured surveys.'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyMappingService - */ private SurveyMappingService $mappingService; public function __construct(SurveyMappingService $surveyMappingService) diff --git a/src/Commands/SurveyheroResponseImportCommand.php b/src/Commands/SurveyheroResponseImportCommand.php index 09feaa5..7b9e84d 100644 --- a/src/Commands/SurveyheroResponseImportCommand.php +++ b/src/Commands/SurveyheroResponseImportCommand.php @@ -17,9 +17,6 @@ class SurveyheroResponseImportCommand extends Command public $description = 'Retrieve survey responses from SurveyHero API and save in the database.'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyResponseImportService - */ private SurveyResponseImportService $importService; public function __construct(SurveyResponseImportService $surveyResponseImportService) diff --git a/src/Commands/SurveyheroSurveyImportCommand.php b/src/Commands/SurveyheroSurveyImportCommand.php index 5a16f22..56a6f19 100644 --- a/src/Commands/SurveyheroSurveyImportCommand.php +++ b/src/Commands/SurveyheroSurveyImportCommand.php @@ -14,9 +14,6 @@ class SurveyheroSurveyImportCommand extends Command public $description = 'Retrieve surveys from SurveyHero API and save in the database.'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyImportService - */ private SurveyImportService $importService; public function __construct(SurveyImportService $surveyImportService) diff --git a/src/Commands/SurveyheroWebhookAddCommand.php b/src/Commands/SurveyheroWebhookAddCommand.php index 7558ca9..22089db 100644 --- a/src/Commands/SurveyheroWebhookAddCommand.php +++ b/src/Commands/SurveyheroWebhookAddCommand.php @@ -16,9 +16,6 @@ class SurveyheroWebhookAddCommand extends Command public $description = 'Automatically generate webhooks for survey responses on your desired URL.'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyWebhookService - */ private SurveyWebhookService $webhookService; public function __construct(SurveyWebhookService $webhookService) diff --git a/src/Commands/SurveyheroWebhookDeleteCommand.php b/src/Commands/SurveyheroWebhookDeleteCommand.php index a6cac1a..f76e2b1 100644 --- a/src/Commands/SurveyheroWebhookDeleteCommand.php +++ b/src/Commands/SurveyheroWebhookDeleteCommand.php @@ -15,9 +15,6 @@ class SurveyheroWebhookDeleteCommand extends Command public $description = 'Delete Surveyhero webhooks'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyWebhookService - */ private SurveyWebhookService $webhookService; public function __construct(SurveyWebhookService $webhookService) diff --git a/src/Commands/SurveyheroWebhookListCommand.php b/src/Commands/SurveyheroWebhookListCommand.php index a88530a..8b879a7 100644 --- a/src/Commands/SurveyheroWebhookListCommand.php +++ b/src/Commands/SurveyheroWebhookListCommand.php @@ -14,9 +14,6 @@ class SurveyheroWebhookListCommand extends Command public $description = 'List webhooks for Surveyhero surveys'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyWebhookService - */ private SurveyWebhookService $webhookService; public function __construct(SurveyWebhookService $webhookService) @@ -42,7 +39,7 @@ public function handle(): int try { $webhooks = $this->webhookService->listWebhooks($survey); $webhookData = []; - foreach($webhooks as $webhook) { + foreach ($webhooks as $webhook) { $webhookData[] = [ $webhook->webhook_id, $webhook->event_type, @@ -52,7 +49,7 @@ public function handle(): int ]; } $this->table( - ['Webhook id','Event type','Url','Status','Created'], + ['Webhook id', 'Event type', 'Url', 'Status', 'Created'], $webhookData ); } catch (\Exception $e) { diff --git a/src/Contracts/ModelContract.php b/src/Contracts/ModelContract.php index e7d00c6..6a32112 100644 --- a/src/Contracts/ModelContract.php +++ b/src/Contracts/ModelContract.php @@ -25,8 +25,6 @@ public function delete(); /** * Returns the table name of the model. - * - * @return string */ public function getTable(): string; } diff --git a/src/Contracts/SurveyAnswerContract.php b/src/Contracts/SurveyAnswerContract.php index 779edf3..a82018b 100644 --- a/src/Contracts/SurveyAnswerContract.php +++ b/src/Contracts/SurveyAnswerContract.php @@ -23,11 +23,6 @@ public function surveyQuestion(): BelongsTo; /** * Translate a variable with $key to $locale - * - * @param string $key - * @param string $locale - * @param bool $useFallbackLocale - * @return mixed */ public function translate(string $key, string $locale = '', bool $useFallbackLocale = true): mixed; } diff --git a/src/Contracts/SurveyContract.php b/src/Contracts/SurveyContract.php index 9c7510f..6fc19f7 100644 --- a/src/Contracts/SurveyContract.php +++ b/src/Contracts/SurveyContract.php @@ -32,9 +32,6 @@ public function getCollectors(): array; /** * Checks if the response timestamp is more recent than the last updated survey timestamp. - * - * @param string $responseLastUpdatedIsoTimestamp - * @return bool */ public function doesResponseNeedsToBeUpdated(string $responseLastUpdatedIsoTimestamp): bool; } diff --git a/src/Contracts/SurveyQuestionContract.php b/src/Contracts/SurveyQuestionContract.php index f11c7c8..9cef427 100644 --- a/src/Contracts/SurveyQuestionContract.php +++ b/src/Contracts/SurveyQuestionContract.php @@ -21,11 +21,6 @@ public function surveyAnswers(): HasMany; /** * Translate a variable with $key to $locale - * - * @param string $key - * @param string $locale - * @param bool $useFallbackLocale - * @return mixed */ public function translate(string $key, string $locale = '', bool $useFallbackLocale = true): mixed; } diff --git a/src/Exports/Sheets/AnswersSheet.php b/src/Exports/Sheets/AnswersSheet.php index 73c557f..a4fd2de 100644 --- a/src/Exports/Sheets/AnswersSheet.php +++ b/src/Exports/Sheets/AnswersSheet.php @@ -12,7 +12,7 @@ use Statikbe\Surveyhero\Contracts\SurveyContract; use Statikbe\Surveyhero\SurveyheroRegistrar; -class AnswersSheet implements FromQuery, WithTitle, WithHeadings, WithMapping, ShouldAutoSize +class AnswersSheet implements FromQuery, ShouldAutoSize, WithHeadings, WithMapping, WithTitle { private SurveyContract $survey; @@ -73,7 +73,6 @@ public function headings(): array /** * @param SurveyAnswerContract $surveyAnswer - * @return array */ public function map($surveyAnswer): array { diff --git a/src/Exports/Sheets/QuestionsSheet.php b/src/Exports/Sheets/QuestionsSheet.php index 8373a9f..e89cacb 100644 --- a/src/Exports/Sheets/QuestionsSheet.php +++ b/src/Exports/Sheets/QuestionsSheet.php @@ -11,7 +11,7 @@ use Statikbe\Surveyhero\Contracts\SurveyContract; use Statikbe\Surveyhero\Contracts\SurveyQuestionContract; -class QuestionsSheet implements FromQuery, WithTitle, WithHeadings, WithMapping, ShouldAutoSize +class QuestionsSheet implements FromQuery, ShouldAutoSize, WithHeadings, WithMapping, WithTitle { private SurveyContract $survey; @@ -63,7 +63,6 @@ public function headings(): array /** * @param SurveyQuestionContract $surveyQuestion - * @return array */ public function map($surveyQuestion): array { diff --git a/src/Exports/Sheets/ResponsesSheet.php b/src/Exports/Sheets/ResponsesSheet.php index e623988..b846880 100644 --- a/src/Exports/Sheets/ResponsesSheet.php +++ b/src/Exports/Sheets/ResponsesSheet.php @@ -10,7 +10,7 @@ use Maatwebsite\Excel\Concerns\WithTitle; use Statikbe\Surveyhero\Contracts\SurveyContract; -class ResponsesSheet implements FromCollection, WithTitle, WithHeadings, ShouldAutoSize +class ResponsesSheet implements FromCollection, ShouldAutoSize, WithHeadings, WithTitle { private SurveyContract $survey; diff --git a/src/Exports/SurveyExport.php b/src/Exports/SurveyExport.php index 8c6b1ea..758af9c 100644 --- a/src/Exports/SurveyExport.php +++ b/src/Exports/SurveyExport.php @@ -10,7 +10,7 @@ use Statikbe\Surveyhero\Exports\Sheets\QuestionsSheet; use Statikbe\Surveyhero\Exports\Sheets\ResponsesSheet; -class SurveyExport implements WithMultipleSheets, ShouldAutoSize +class SurveyExport implements ShouldAutoSize, WithMultipleSheets { use Exportable; @@ -47,7 +47,6 @@ public function sheets(): array * Override default worksheets list. * * @param array $sheets - * @return void */ public function setSheets(array $sheets): void { diff --git a/src/Http/SurveyheroClient.php b/src/Http/SurveyheroClient.php index 7e7918f..b5f6fcd 100644 --- a/src/Http/SurveyheroClient.php +++ b/src/Http/SurveyheroClient.php @@ -46,7 +46,7 @@ public function getSurveyResponseAnswers(string|int $surveyId, string|int $respo return $answerData->successful() ? json_decode($answerData->body()) : null; } - public function getSurveyElements(string|int $surveyId, string $lang = null): array + public function getSurveyElements(string|int $surveyId, ?string $lang = null): array { $questionsData = $this->fetchFromSurveyHero(sprintf('surveys/%s/elements%s', $surveyId, $lang ? '?lang='.$lang : null)); $questions = json_decode($questionsData->body()); @@ -54,7 +54,7 @@ public function getSurveyElements(string|int $surveyId, string $lang = null): ar return $questions ? $questions->elements : []; } - public function getSurveyQuestions(string|int $surveyId, string $lang = null): array + public function getSurveyQuestions(string|int $surveyId, ?string $lang = null): array { $questionsData = $this->fetchFromSurveyHero(sprintf('surveys/%s/questions%s', $surveyId, $lang ? '?lang='.$lang : null)); $questions = json_decode($questionsData->body()); @@ -120,8 +120,8 @@ private function fetchFromSurveyHero(string $urlPath, array $queryStringArgs = [ $this->preventThrottle(); $response = Http::retry(3, 800) - ->withBasicAuth(config('surveyhero.api_username'), config('surveyhero.api_password')) - ->get(config('surveyhero.api_url').$urlPath, $queryStringArgs); + ->withBasicAuth(config('surveyhero.api_username'), config('surveyhero.api_password')) + ->get(config('surveyhero.api_url').$urlPath, $queryStringArgs); $this->updateThrottle(); @@ -140,8 +140,8 @@ private function postToSurveyHero(string $urlPath, array $queryStringArgs = []): $this->preventThrottle(); $response = Http::retry(3, 600) - ->withBasicAuth(config('surveyhero.api_username'), config('surveyhero.api_password')) - ->post(config('surveyhero.api_url').$urlPath, $queryStringArgs); + ->withBasicAuth(config('surveyhero.api_username'), config('surveyhero.api_password')) + ->post(config('surveyhero.api_url').$urlPath, $queryStringArgs); $this->updateThrottle(); @@ -160,8 +160,8 @@ private function deleteFromSurveyHero(string $urlPath, array $queryStringArgs = $this->preventThrottle(); $response = Http::retry(3, 600) - ->withBasicAuth(config('surveyhero.api_username'), config('surveyhero.api_password')) - ->delete(config('surveyhero.api_url').$urlPath, $queryStringArgs); + ->withBasicAuth(config('surveyhero.api_username'), config('surveyhero.api_password')) + ->delete(config('surveyhero.api_url').$urlPath, $queryStringArgs); $this->updateThrottle(); diff --git a/src/Models/Survey.php b/src/Models/Survey.php index 6080d8e..57d5b47 100644 --- a/src/Models/Survey.php +++ b/src/Models/Survey.php @@ -14,9 +14,9 @@ class Survey extends Model implements SurveyContract { + use HasCollectors; use HasFactory; use HasQuestionMapping; - use HasCollectors; protected $guarded = []; diff --git a/src/Services/AbstractSurveyheroAPIService.php b/src/Services/AbstractSurveyheroAPIService.php index 7377897..05e524b 100644 --- a/src/Services/AbstractSurveyheroAPIService.php +++ b/src/Services/AbstractSurveyheroAPIService.php @@ -6,9 +6,6 @@ class AbstractSurveyheroAPIService { - /** - * @var \Statikbe\Surveyhero\Http\SurveyheroClient - */ protected SurveyheroClient $client; public function __construct() diff --git a/src/Services/Factories/QuestionAndAnswerCreator/AbstractQuestionAndAnswerCreator.php b/src/Services/Factories/QuestionAndAnswerCreator/AbstractQuestionAndAnswerCreator.php index b1ea3b5..b6d3008 100644 --- a/src/Services/Factories/QuestionAndAnswerCreator/AbstractQuestionAndAnswerCreator.php +++ b/src/Services/Factories/QuestionAndAnswerCreator/AbstractQuestionAndAnswerCreator.php @@ -12,13 +12,6 @@ abstract class AbstractQuestionAndAnswerCreator implements QuestionAndAnswerCreator { /** - * @param SurveyContract $survey - * @param string $lang - * @param string $questionId - * @param string|null $label - * @param string|null $subquestionId - * @return SurveyQuestionContract - * * @throws \Statikbe\Surveyhero\Exceptions\QuestionNotMappedException * @throws \Statikbe\Surveyhero\Exceptions\SurveyNotMappedException */ @@ -57,11 +50,6 @@ protected function getChoiceMapping(string|int $choiceId, string|int $questionId } /** - * @param mixed $mappedChoice - * @param string $dataType - * @param array $responseData - * @param \stdClass $surveyheroChoice - * * @throws AnswerNotMappedException */ protected function setChoiceAndConvertToDataType(mixed $mappedChoice, diff --git a/src/Services/Factories/QuestionAndAnswerCreator/ChoiceListQuestionAndAnswerCreator.php b/src/Services/Factories/QuestionAndAnswerCreator/ChoiceListQuestionAndAnswerCreator.php index 00bec93..fd06ce7 100644 --- a/src/Services/Factories/QuestionAndAnswerCreator/ChoiceListQuestionAndAnswerCreator.php +++ b/src/Services/Factories/QuestionAndAnswerCreator/ChoiceListQuestionAndAnswerCreator.php @@ -12,11 +12,6 @@ class ChoiceListQuestionAndAnswerCreator extends AbstractQuestionAndAnswerCreato const TYPE = 'choice_list'; /** - * @param \stdClass $question - * @param SurveyContract $survey - * @param string $lang - * @return SurveyQuestionContract|array - * * @throws \Statikbe\Surveyhero\Exceptions\AnswerNotMappedException * @throws \Statikbe\Surveyhero\Exceptions\QuestionNotMappedException * @throws \Statikbe\Surveyhero\Exceptions\SurveyNotMappedException diff --git a/src/Services/Factories/QuestionAndAnswerCreator/InputQuestionAndAnswerCreator.php b/src/Services/Factories/QuestionAndAnswerCreator/InputQuestionAndAnswerCreator.php index 4e6ac76..530b013 100644 --- a/src/Services/Factories/QuestionAndAnswerCreator/InputQuestionAndAnswerCreator.php +++ b/src/Services/Factories/QuestionAndAnswerCreator/InputQuestionAndAnswerCreator.php @@ -16,6 +16,7 @@ class InputQuestionAndAnswerCreator extends AbstractQuestionAndAnswerCreator public function updateOrCreateQuestionAndAnswer(\stdClass $question, SurveyContract $survey, string $lang): SurveyQuestionContract|array { $surveyQuestion = $this->updateOrCreateQuestion($survey, $lang, $question->element_id, $question->question->question_text); + //the answer is different for each user entry, so we cannot save answers for this type of question. return $surveyQuestion; } diff --git a/src/Services/Factories/QuestionAndAnswerCreator/QuestionAndAnswerCreator.php b/src/Services/Factories/QuestionAndAnswerCreator/QuestionAndAnswerCreator.php index fe1fd8e..17a8e7d 100644 --- a/src/Services/Factories/QuestionAndAnswerCreator/QuestionAndAnswerCreator.php +++ b/src/Services/Factories/QuestionAndAnswerCreator/QuestionAndAnswerCreator.php @@ -9,11 +9,6 @@ interface QuestionAndAnswerCreator { /** - * @param \stdClass $question - * @param SurveyContract $survey - * @param string $lang - * @return SurveyQuestionContract|array - * * @throws AnswerNotMappedException */ public function updateOrCreateQuestionAndAnswer(\stdClass $question, SurveyContract $survey, string $lang): SurveyQuestionContract|array; diff --git a/src/Services/Factories/QuestionMapper/AbstractQuestionMapper.php b/src/Services/Factories/QuestionMapper/AbstractQuestionMapper.php index e6dc28c..3d4273f 100644 --- a/src/Services/Factories/QuestionMapper/AbstractQuestionMapper.php +++ b/src/Services/Factories/QuestionMapper/AbstractQuestionMapper.php @@ -5,10 +5,6 @@ abstract class AbstractQuestionMapper implements QuestionMapper { /** - * @param int $questionId - * @param string $questionType - * @param string $mappedDataType - * @param int|string $questionFieldSuffix * @return array{'question_id': int, 'type': string, 'field': string, 'mapped_data_type': string } */ public function createQuestionMap(int $questionId, string $questionType, string $mappedDataType, int|string $questionFieldSuffix): array diff --git a/src/Services/Factories/ResponseCreator/AbstractQuestionResponseCreator.php b/src/Services/Factories/ResponseCreator/AbstractQuestionResponseCreator.php index 3c416bd..2a3adc9 100644 --- a/src/Services/Factories/ResponseCreator/AbstractQuestionResponseCreator.php +++ b/src/Services/Factories/ResponseCreator/AbstractQuestionResponseCreator.php @@ -14,15 +14,9 @@ abstract class AbstractQuestionResponseCreator implements QuestionResponseCreator { - /** - * @param string|int $surveyheroQuestionId - * @param SurveyResponseContract $response - * @param string|int|null $surveyheroAnswerId - * @return SurveyQuestionResponseContract|null - */ protected function findExistingQuestionResponse(string|int $surveyheroQuestionId, - SurveyResponseContract $response, - string|int $surveyheroAnswerId = null): ?SurveyQuestionResponseContract + SurveyResponseContract $response, + string|int|null $surveyheroAnswerId = null): ?SurveyQuestionResponseContract { $query = app(SurveyheroRegistrar::class)->getSurveyQuestionResponseClass()::whereHas('surveyQuestion', function ($q) use ($surveyheroQuestionId) { $q->where('surveyhero_question_id', $surveyheroQuestionId); @@ -37,13 +31,8 @@ protected function findExistingQuestionResponse(string|int $surveyheroQuestionId return $query->first(); } - /** - * @param string|int $surveyheroQuestionId - * @param SurveyResponseContract $response - * @return Collection - */ protected function findAllExistingQuestionResponses(string|int $surveyheroQuestionId, - SurveyResponseContract $response): Collection + SurveyResponseContract $response): Collection { $query = app(SurveyheroRegistrar::class)->getSurveyQuestionResponseClass()::whereHas('surveyQuestion', function ($q) use ($surveyheroQuestionId) { $q->where('surveyhero_question_id', $surveyheroQuestionId); @@ -53,9 +42,6 @@ protected function findAllExistingQuestionResponses(string|int $surveyheroQuesti } /** - * @param string $surveyheroQuestionId - * @return SurveyQuestionContract - * * @throws QuestionNotImportedException */ protected function findSurveyQuestion(string $surveyheroQuestionId): SurveyQuestionContract @@ -82,14 +68,11 @@ protected function findSurveyAnswer(SurveyQuestionContract $question, string $su } /** - * @param SurveyQuestionContract $question - * @param SurveyResponseContract $response - * @param SurveyAnswerContract|null $answer * @return array{ 'survey_question_id': int, 'survey_response_id': int } */ protected function createSurveyQuestionResponseData(SurveyQuestionContract $question, - SurveyResponseContract $response, - ?SurveyAnswerContract $answer): array + SurveyResponseContract $response, + ?SurveyAnswerContract $answer): array { return [ 'survey_question_id' => $question->id, @@ -99,11 +82,6 @@ protected function createSurveyQuestionResponseData(SurveyQuestionContract $ques } /** - * @param mixed $mappedChoice - * @param string $dataType - * @param array $responseData - * @param \stdClass|null $surveyheroChoice - * * @throws AnswerNotMappedException */ protected function setChoiceAndConvertToDataType(mixed $mappedChoice, @@ -157,7 +135,7 @@ protected function fetchOrCreateInputAnswer(SurveyQuestionContract $surveyQuesti protected function transformInputToDataType(mixed $input, string $dataType): mixed { - switch($dataType) { + switch ($dataType) { case SurveyAnswerContract::CONVERTED_TYPE_INT: return intval($input); case SurveyAnswerContract::CONVERTED_TYPE_STRING: diff --git a/src/Services/Factories/ResponseCreator/ChoiceTableResponseCreator.php b/src/Services/Factories/ResponseCreator/ChoiceTableResponseCreator.php index d9da1da..f2e7e1b 100644 --- a/src/Services/Factories/ResponseCreator/ChoiceTableResponseCreator.php +++ b/src/Services/Factories/ResponseCreator/ChoiceTableResponseCreator.php @@ -15,8 +15,8 @@ class ChoiceTableResponseCreator extends AbstractQuestionResponseCreator * {@inheritDoc} */ public function updateOrCreateQuestionResponse(\stdClass $surveyheroQuestionResponse, - SurveyResponseContract $response, - array $questionMapping): SurveyQuestionResponseContract|array + SurveyResponseContract $response, + array $questionMapping): SurveyQuestionResponseContract|array { /* Config question_mapping data structure: * [ diff --git a/src/Services/Factories/ResponseCreator/NumberResponseCreator.php b/src/Services/Factories/ResponseCreator/NumberResponseCreator.php index 6f70507..3756ecb 100644 --- a/src/Services/Factories/ResponseCreator/NumberResponseCreator.php +++ b/src/Services/Factories/ResponseCreator/NumberResponseCreator.php @@ -15,8 +15,8 @@ class NumberResponseCreator extends AbstractQuestionResponseCreator * {@inheritDoc} */ public function updateOrCreateQuestionResponse(\stdClass $surveyheroQuestionResponse, - SurveyResponseContract $response, - array $questionMapping): SurveyQuestionResponseContract|array + SurveyResponseContract $response, + array $questionMapping): SurveyQuestionResponseContract|array { /* Config question_mapping data structure: * [ diff --git a/src/Services/Factories/ResponseCreator/QuestionResponseCreator.php b/src/Services/Factories/ResponseCreator/QuestionResponseCreator.php index aaedcff..587ba5f 100644 --- a/src/Services/Factories/ResponseCreator/QuestionResponseCreator.php +++ b/src/Services/Factories/ResponseCreator/QuestionResponseCreator.php @@ -8,9 +8,6 @@ interface QuestionResponseCreator { /** - * @param \stdClass $surveyheroQuestionResponse - * @param SurveyResponseContract $response - * @param array $questionMapping * @return SurveyQuestionResponseContract|array * * @throws \Statikbe\Surveyhero\Exceptions\AnswerNotImportedException @@ -18,6 +15,6 @@ interface QuestionResponseCreator * @throws \Statikbe\Surveyhero\Exceptions\QuestionNotImportedException */ public function updateOrCreateQuestionResponse(\stdClass $surveyheroQuestionResponse, - SurveyResponseContract $response, - array $questionMapping): SurveyQuestionResponseContract|array; + SurveyResponseContract $response, + array $questionMapping): SurveyQuestionResponseContract|array; } diff --git a/src/Services/Factories/ResponseCreator/TextResponseCreator.php b/src/Services/Factories/ResponseCreator/TextResponseCreator.php index db1ff66..71007fa 100644 --- a/src/Services/Factories/ResponseCreator/TextResponseCreator.php +++ b/src/Services/Factories/ResponseCreator/TextResponseCreator.php @@ -15,8 +15,8 @@ class TextResponseCreator extends AbstractQuestionResponseCreator * {@inheritDoc} */ public function updateOrCreateQuestionResponse(\stdClass $surveyheroQuestionResponse, - SurveyResponseContract $response, - array $questionMapping): SurveyQuestionResponseContract|array + SurveyResponseContract $response, + array $questionMapping): SurveyQuestionResponseContract|array { /* Config question_mapping data structure: * [ diff --git a/src/Services/Info/ResponseImportInfo.php b/src/Services/Info/ResponseImportInfo.php index 3a56f56..c4f5d6b 100644 --- a/src/Services/Info/ResponseImportInfo.php +++ b/src/Services/Info/ResponseImportInfo.php @@ -66,49 +66,31 @@ public function hasUnimportedAnswers(): bool return ! empty($this->unimportedAnswers); } - /** - * @return int - */ public function getTotalResponsesImported(): int { return $this->totalResponsesImported; } - /** - * @param int $totalResponsesImported - */ public function setTotalResponsesImported(int $totalResponsesImported): void { $this->totalResponsesImported = $totalResponsesImported; } - /** - * @return array - */ public function getUnimportedQuestions(): array { return $this->unimportedQuestions; } - /** - * @return array - */ public function getUnimportedAnswers(): array { return $this->unimportedAnswers; } - /** - * @return Carbon|null - */ public function getSurveyLastUpdatedAt(): ?Carbon { return $this->surveyLastUpdatedAt; } - /** - * @param Carbon|null $surveyLastUpdatedAt - */ public function setSurveyLastUpdatedAt(?Carbon $surveyLastUpdatedAt): void { if ($surveyLastUpdatedAt) { diff --git a/src/Services/SurveyImportService.php b/src/Services/SurveyImportService.php index e4b6b88..670ab44 100644 --- a/src/Services/SurveyImportService.php +++ b/src/Services/SurveyImportService.php @@ -9,7 +9,6 @@ class SurveyImportService extends AbstractSurveyheroAPIService { /** - * @param Collection|null $surveyIdsToImport * @return array{ 'imported': array, 'notImported': array } */ public function importSurveys(?Collection $surveyIdsToImport): array diff --git a/src/Services/SurveyMappingService.php b/src/Services/SurveyMappingService.php index a510d8a..6498842 100644 --- a/src/Services/SurveyMappingService.php +++ b/src/Services/SurveyMappingService.php @@ -25,8 +25,6 @@ public function __construct() /** * Creates a basic question mapping based on the API to kickstart the configuration. * - * @param SurveyContract $survey - * @return array * * @see SurveyheroMapperCommand */ @@ -72,8 +70,6 @@ public function map(SurveyContract $survey): array /** * Returns the question mapping from the configuration/api for the given survey * - * @param SurveyContract $survey - * @return array * * @throws SurveyNotMappedException */ @@ -91,8 +87,6 @@ public function getSurveyQuestionMapping(SurveyContract $survey): array /** * Returns the collectors from the configuration/api for the given survey * - * @param SurveyContract $survey - * @return array * * @throws SurveyNotMappedException */ @@ -110,8 +104,6 @@ public function getSurveyCollectors(SurveyContract $survey): array /** * Returns the survey mapping from the configuration for the given survey. * - * @param SurveyContract $survey - * @return array|null * * @throws SurveyNotMappedException */ @@ -137,9 +129,6 @@ public function getSurveyMappingFromConfig(SurveyContract $survey): ?array /** * Returns the question mapping from the configuration for a given survey and question ID. * - * @param SurveyContract $survey - * @param int|string $questionId - * @return array|null * * @throws SurveyNotMappedException */ @@ -155,10 +144,6 @@ public function getQuestionMappingForSurvey(SurveyContract $survey, int|string $ /** * Returns the question mapping based on all question mappings for a survey and the question ID. - * - * @param array $surveyQuestionMapping - * @param int|string $questionId - * @return array|null */ public function getQuestionMapping(array $surveyQuestionMapping, int|string $questionId): ?array { @@ -175,9 +160,8 @@ public function getQuestionMapping(array $surveyQuestionMapping, int|string $que /** * Returns the subquestion mapping for questions with subquestions. * - * @param string|int $questionId The subquestion ID. + * @param string|int $questionId The subquestion ID. * @param array $surveyQuestionMapping The question mapping. It needs to have a subquestion_mapping key. - * @return array */ public function getSubquestionMapping(string|int $questionId, array $surveyQuestionMapping): array { @@ -193,11 +177,6 @@ public function getSubquestionMapping(string|int $questionId, array $surveyQuest } /** - * @param SurveyContract $survey - * @param string $questionId - * @param string|null $subquestionId - * @return string - * * @throws QuestionNotMappedException * @throws SurveyNotMappedException */ diff --git a/src/Services/SurveyQuestionsAndAnswersImportService.php b/src/Services/SurveyQuestionsAndAnswersImportService.php index 93e778f..e7d7f5e 100644 --- a/src/Services/SurveyQuestionsAndAnswersImportService.php +++ b/src/Services/SurveyQuestionsAndAnswersImportService.php @@ -13,8 +13,6 @@ class SurveyQuestionsAndAnswersImportService extends AbstractSurveyheroAPIService { /** - * @param SurveyContract $survey - * * @throws \Exception */ public function importSurveyQuestionsAndAnswers(SurveyContract $survey): array @@ -49,7 +47,7 @@ public function importSurveyQuestionsAndAnswers(SurveyContract $survey): array return $notImported; } - private function getQuestionAndAnswerCreator(string $surveyheroFieldType): QuestionAndAnswerCreator|null + private function getQuestionAndAnswerCreator(string $surveyheroFieldType): ?QuestionAndAnswerCreator { return match ($surveyheroFieldType) { ChoiceListQuestionAndAnswerCreator::TYPE => new ChoiceListQuestionAndAnswerCreator(), diff --git a/src/Services/SurveyResponseImportService.php b/src/Services/SurveyResponseImportService.php index fa6e4c6..2b7ec81 100644 --- a/src/Services/SurveyResponseImportService.php +++ b/src/Services/SurveyResponseImportService.php @@ -22,9 +22,6 @@ class SurveyResponseImportService extends AbstractSurveyheroAPIService { const SURVEYHERO_STATUS_COMPLETED = 'completed'; - /** - * @var \Statikbe\Surveyhero\Services\SurveyMappingService - */ private SurveyMappingService $surveyMappingService; public function __construct(SurveyMappingService $surveyMappingService) @@ -34,9 +31,6 @@ public function __construct(SurveyMappingService $surveyMappingService) } /** - * @param SurveyContract $survey - * @return ResponseImportInfo - * * @throws ResponseCreatorNotImplemented * @throws SurveyNotMappedException */ @@ -75,15 +69,12 @@ public function importSurveyResponses(SurveyContract $survey): ResponseImportInf } /** - * @param $responseId - * @param SurveyContract $survey - * @param array|null $surveyQuestionMapping - * @return ResponseImportInfo | null A list of surveyhero question ids that could not be imported. + * @return ResponseImportInfo | null A list of surveyhero question ids that could not be imported. * * @throws ResponseCreatorNotImplemented * @throws SurveyNotMappedException */ - public function importSurveyResponse($responseId, SurveyContract $survey, array $surveyQuestionMapping = null): ResponseImportInfo|null + public function importSurveyResponse($responseId, SurveyContract $survey, ?array $surveyQuestionMapping = null): ?ResponseImportInfo { $importInfo = new ResponseImportInfo(); diff --git a/src/Services/SurveyWebhookService.php b/src/Services/SurveyWebhookService.php index fd8dabf..6541e59 100644 --- a/src/Services/SurveyWebhookService.php +++ b/src/Services/SurveyWebhookService.php @@ -9,7 +9,6 @@ class SurveyWebhookService extends AbstractSurveyheroAPIService /** * Lists all webhooks for a certain Surveyhero survey * - * @param SurveyContract $survey * @return void */ public function listWebhooks(SurveyContract $survey): ?array @@ -19,9 +18,6 @@ public function listWebhooks(SurveyContract $survey): ?array /** * Creates a webhook for Surveyhero to notify on the given event type. - * - * @param SurveyContract $survey - * @return void */ public function createWebhook(SurveyContract $survey, string $eventType, string $url): void { @@ -30,10 +26,6 @@ public function createWebhook(SurveyContract $survey, string $eventType, string /** * Deletes a webhooks for a certain Surveyhero survey - * - * @param SurveyContract $survey - * @param string|int $webhookId - * @return void */ public function deleteWebhook(SurveyContract $survey, string|int $webhookId): void { diff --git a/src/SurveyheroRegistrar.php b/src/SurveyheroRegistrar.php index 7cd052b..799799c 100644 --- a/src/SurveyheroRegistrar.php +++ b/src/SurveyheroRegistrar.php @@ -36,8 +36,6 @@ public function __construct() /** * Get an instance of the survey class. - * - * @return SurveyContract */ public function getSurveyClass(): SurveyContract { @@ -55,8 +53,6 @@ public function setSurveyClass($surveyClass): self /** * Get an instance of the survey question class. - * - * @return SurveyQuestionContract */ public function getSurveyQuestionClass(): SurveyQuestionContract { @@ -74,8 +70,6 @@ public function setSurveyQuestionClass($surveyQuestionClass): self /** * Get an instance of the survey answer class. - * - * @return SurveyAnswerContract */ public function getSurveyAnswerClass(): SurveyAnswerContract { @@ -93,8 +87,6 @@ public function setSurveyAnswerClass($surveyAnswerClass): self /** * Get an instance of the survey class. - * - * @return SurveyResponseContract */ public function getSurveyResponseClass(): SurveyResponseContract { @@ -112,8 +104,6 @@ public function setSurveyResponseClass($surveyResponseClass): self /** * Get an instance of the survey question response class. - * - * @return SurveyQuestionResponseContract */ public function getSurveyQuestionResponseClass(): SurveyQuestionResponseContract {