diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 66febb3..3ac715b 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: [ '8.1', '8.2' ] + php: [ '8.2', '8.3' ] composer-flags: [ '', '--prefer-lowest' ] steps: diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 50110cf..6ece1a3 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -14,18 +14,19 @@ ->setUsingCache(true) ->setRules([ 'psr_autoloading' => true, - '@PSR12' => true, + '@PER-CS' => true, 'array_syntax' => ['syntax' => 'short'], 'no_unused_imports' => true, 'blank_line_after_namespace' => true, + 'braces_position' => true, 'single_space_around_construct' => true, 'control_structure_braces' => true, - 'curly_braces_position' => true, 'control_structure_continuation_position' => true, 'declare_parentheses' => true, 'statement_indentation' => true, 'no_multiple_statements_per_line' => true, 'no_extra_blank_lines' => true, + 'nullable_type_declaration' => ['syntax' => 'union'], 'class_definition' => true, 'declare_strict_types' => true, 'elseif' => true, @@ -39,7 +40,6 @@ 'no_closing_tag' => true, 'no_blank_lines_after_class_opening' => true, 'no_spaces_after_function_name' => true, - 'no_spaces_inside_parenthesis' => true, 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_whitespace_in_blank_line' => true, @@ -50,6 +50,7 @@ 'single_line_after_imports' => true, 'single_trait_insert_per_statement' => true, 'short_scalar_cast' => true, + 'spaces_inside_parentheses' => true, 'switch_case_semicolon_to_colon' => true, 'switch_case_space' => true, 'single_quote' => true, diff --git a/README.md b/README.md index 4d96f54..72c5ba5 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ composer require petersons/d2l-client ## Requirements -* [PHP 8.1](https://www.php.net/releases/8_1_0.php) or greater +* [PHP 8.2](https://www.php.net/releases/8_2_0.php) or greater ## Usage example @@ -78,7 +78,7 @@ Docker dependencies for local development: 0. Build the Docker image ```bash - dev/bin/docker-compose build --build-arg PHP_VERSION=8.1 php + dev/bin/docker-compose build --build-arg PHP_VERSION=8.2 php ``` 0. Install library dependencies diff --git a/composer.json b/composer.json index c32544e..ff1bb44 100644 --- a/composer.json +++ b/composer.json @@ -13,20 +13,19 @@ } ], "require": { - "php": "^8.1", + "php": "^8.2", "ext-curl": "*", "ext-simplexml": "*", - "illuminate/collections": "^9.0 || ^10.0", - "illuminate/contracts": "^9.0 || ^10.0", - "illuminate/support": "^9.0 || ^10.0", - "nesbot/carbon": "^2.67", - "symfony/http-client": "^5.4.21 || ^6.3" + "illuminate/collections": "^10.0 || ^11.0", + "illuminate/contracts": "^10.0 || ^11.0", + "illuminate/support": "^10.0 || ^11.0", + "nesbot/carbon": "^2.72 || ^3.0", + "symfony/http-client": "^6.4 || ^7.0" }, "require-dev": { - "friendsofphp/php-cs-fixer": "^3.46", - "illuminate/container": "^9.0 || ^10.0", - "phpunit/phpunit": "^9.6.9", - "nikic/php-parser": "^4.15.5" + "friendsofphp/php-cs-fixer": "^3.52", + "illuminate/container": "^10.0 || ^11.0", + "phpunit/phpunit": "^11.0" }, "autoload": { "psr-4": { diff --git a/dev/docker/Dockerfile b/dev/docker/Dockerfile index 0c09e0f..0220578 100644 --- a/dev/docker/Dockerfile +++ b/dev/docker/Dockerfile @@ -1,10 +1,10 @@ -ARG PHP_VERSION=8.1 +ARG PHP_VERSION=8.2 FROM php:${PHP_VERSION}-cli-alpine LABEL maintainer="Antonio Pauletich " -ARG COMPOSER_VERSION=2.5.8 -ARG XDEBUG_VERSION=3.2.1 +ARG COMPOSER_VERSION=2.7.2 +ARG XDEBUG_VERSION=3.3.1 ENV XDEBUG_START_WITH_REQUEST "no" diff --git a/phpunit.xml b/phpunit.xml index ce81483..3db3988 100644 --- a/phpunit.xml +++ b/phpunit.xml @@ -2,31 +2,26 @@ + failOnWarning="true"> ./tests/Unit - + ./src ./src/Laravel/config - + diff --git a/src/AuthenticatedUriFactory.php b/src/AuthenticatedUriFactory.php index 776daed..633fdd5 100644 --- a/src/AuthenticatedUriFactory.php +++ b/src/AuthenticatedUriFactory.php @@ -14,8 +14,7 @@ public function __construct( private string $appKey, private string $lmsUserId, private string $lmsUserKey - ) { - } + ) {} public function createAuthenticatedUri(string $url, string $httpMethod): string { diff --git a/src/Contracts/ClientInterface.php b/src/Contracts/ClientInterface.php index 83cb019..6e9784e 100644 --- a/src/Contracts/ClientInterface.php +++ b/src/Contracts/ClientInterface.php @@ -103,7 +103,7 @@ public function validateGuid(Guid $guid, string $orgDefinedId): bool; /** * @link https://docs.valence.desire2learn.com/res/dataExport.html#get--d2l-api-lp-(version)-dataExport-bds * @throws ApiException - * @return Collection|DataSetReportInfo[] + * @return Collection */ public function getBrightspaceDataExportList(): Collection; @@ -117,7 +117,7 @@ public function getBrightspaceDataExportItems(int $page = 1, int $pageSize = 100 * @link https://docs.valence.desire2learn.com/res/dataExport.html#get--d2l-api-lp-(version)-dataExport-bds * @throws ApiException */ - public function findBrightspaceDataExportItemByName(string $name): ?BrightspaceDataSetReportInfo; + public function findBrightspaceDataExportItemByName(string $name): BrightspaceDataSetReportInfo|null; /** * @link https://docs.valence.desire2learn.com/res/quiz.html#get--d2l-api-le-(version)-(orgUnitId)-quizzes-(quizId) @@ -129,11 +129,11 @@ public function getQuizById(int $orgUnitId, int $quizId): Quiz; * @link https://docs.valence.desire2learn.com/res/quiz.html#get--d2l-api-le-(version)-(orgUnitId)-quizzes- * @throws ApiException */ - public function quizzesList(int $orgUnitId, ?string $bookmark = null): QuizListPage; + public function quizzesList(int $orgUnitId, string|null $bookmark = null): QuizListPage; /** * @link https://docs.valence.desire2learn.com/res/quiz.html#get--d2l-api-le-(version)-(orgUnitId)-quizzes- - * @return Collection|Quiz[] + * @return Collection */ public function getQuizzesForAnOrganizationUnit(int $orgUnitId): Collection; @@ -141,18 +141,18 @@ public function getQuizzesForAnOrganizationUnit(int $orgUnitId): Collection; * @link https://docs.valence.desire2learn.com/res/quiz.html#get--d2l-api-le-(version)-(orgUnitId)-quizzes-(quizId)-questions- * @throws ApiException */ - public function quizQuestionsList(int $orgUnitId, int $quizId, ?string $bookmark = null): QuizQuestionListPage; + public function quizQuestionsList(int $orgUnitId, int $quizId, string|null $bookmark = null): QuizQuestionListPage; /** * @link https://docs.valence.desire2learn.com/res/quiz.html#get--d2l-api-le-(version)-(orgUnitId)-quizzes-(quizId)-questions- - * @return Collection|QuizQuestion[] + * @return Collection */ public function getQuizQuestionsForAQuiz(int $orgUnitId, int $quizId): Collection; /** * @link https://docs.valence.desire2learn.com/res/quiz.html#get--d2l-api-le-(version)-(orgUnitId)-quizzes-(quizId)-questions- * @throws ApiException - * @return Collection|OrganizationUnitUser[] + * @return Collection */ public function getEnrolledUsersForAnOrganizationUnit(int $orgUnitId): Collection; @@ -171,28 +171,28 @@ public function getOrganizationInfo(): OrganizationInfo; /** * @link https://docs.valence.desire2learn.com/res/orgunit.html#get--d2l-api-lp-(version)-orgstructure- * @throws ApiException - * @return Collection|OrgUnitProperties[] + * @return Collection */ public function getOrganizationStructure(): Collection; /** * @link https://docs.valence.desire2learn.com/res/orgunit.html#get--d2l-api-lp-(version)-orgstructure-(orgUnitId)-descendants-paged- * @throws ApiException - * @return Collection|OrgUnit[] + * @return Collection */ public function getDescendentUnitsForAnOrganizationUnit(int $orgUnitId): Collection; /** * @link https://docs.valence.desire2learn.com/res/grade.html#get--d2l-api-le-(version)-(orgUnitId)-grades-categories- * @throws ApiException - * @return Collection|GradeObjectCategory[] + * @return Collection */ public function getGradeCategoriesForAnOrganizationUnit(int $orgUnitId): Collection; /** * @link https://docs.valence.desire2learn.com/res/dataExport.html#get--d2l-api-lp-(version)-dataExport-list * @throws ApiException - * @return Collection|DataSetData[] + * @return Collection */ public function getDataExportList(): Collection; @@ -205,14 +205,14 @@ public function createDataExport(CreateExportJobData $createExportJobData): Expo /** * @link https://docs.valence.desire2learn.com/res/content.html#get--d2l-api-le-(version)-(orgUnitId)-content-root- * @throws ApiException - * @return Collection|Module[] + * @return Collection */ public function getRootModulesForAnOrganizationUnit(int $orgUnitId): Collection; /** * @link https://docs.valence.desire2learn.com/res/content.html#get--d2l-api-le-(version)-(orgUnitId)-content-modules-(moduleId)-structure- * @throws ApiException - * @return Collection|ContentObject[] + * @return Collection */ public function getModuleStructureForAnOrganizationUnit(int $orgUnitId, int $moduleId): Collection; @@ -226,7 +226,7 @@ public function updateContentTopicCompletion(ContentTopicCompletionUpdate $updat * Retrieve all the sections for a provided org unit. * @link https://docs.valence.desire2learn.com/res/enroll.html#get--d2l-api-lp-(version)-(orgUnitId)-sections- * @throws ApiException - * @return Collection|Section[] + * @return Collection
*/ public function getSectionsForOrganizationUnit(int $orgUnitId): Collection; } diff --git a/src/CourseUrlGenerator.php b/src/CourseUrlGenerator.php index f29c304..2868d57 100644 --- a/src/CourseUrlGenerator.php +++ b/src/CourseUrlGenerator.php @@ -13,8 +13,7 @@ final class CourseUrlGenerator public function __construct( private string $d2lHost, private string $d2lGuidLoginUri - ) { - } + ) {} /** * @throws UserOrgDefinedIdMissingException diff --git a/src/DTO/BrightspaceDataSet/BrightspaceDataSetReportInfo.php b/src/DTO/BrightspaceDataSet/BrightspaceDataSetReportInfo.php index 4659700..22095b0 100644 --- a/src/DTO/BrightspaceDataSet/BrightspaceDataSetReportInfo.php +++ b/src/DTO/BrightspaceDataSet/BrightspaceDataSetReportInfo.php @@ -18,14 +18,13 @@ public function __construct( private string $name, private string $description, private bool $fullDataset, - private ?CarbonImmutable $createdDate = null, - private ?string $downloadLink = null, - private ?float $downloadSize = null, - private ?string $version = null, - private ?Collection $previousDataSets = null, - private ?CarbonImmutable $queuedForProcessingDate = null - ) { - } + private CarbonImmutable|null $createdDate = null, + private string|null $downloadLink = null, + private float|null $downloadSize = null, + private string|null $version = null, + private Collection|null $previousDataSets = null, + private CarbonImmutable|null $queuedForProcessingDate = null + ) {} public function getPluginId(): string { @@ -47,35 +46,35 @@ public function isFullDataset(): bool return $this->fullDataset; } - public function getCreatedDate(): ?CarbonImmutable + public function getCreatedDate(): CarbonImmutable|null { return $this->createdDate; } - public function getDownloadLink(): ?string + public function getDownloadLink(): string|null { return $this->downloadLink; } - public function getDownloadSize(): ?float + public function getDownloadSize(): float|null { return $this->downloadSize; } - public function getVersion(): ?string + public function getVersion(): string|null { return $this->version; } /** - * @return Collection|null|BrightspaceDataSetReportInfo[] + * @return Collection|null */ - public function getPreviousDataSets(): ?Collection + public function getPreviousDataSets(): Collection|null { return $this->previousDataSets; } - public function getQueuedForProcessingDate(): ?CarbonImmutable + public function getQueuedForProcessingDate(): CarbonImmutable|null { return $this->queuedForProcessingDate; } @@ -87,12 +86,12 @@ public function toArray(): array 'Name' => $this->name, 'Description' => $this->description, 'FullDataSet' => $this->fullDataset, - 'CreatedDate' => null !== $this->createdDate ? $this->createdDate->toDateTime() : null, + 'CreatedDate' => $this->createdDate?->toDateTime(), 'DownloadLink' => $this->downloadLink, 'DownloadSize' => $this->downloadSize, 'Version' => $this->version, - 'PreviousDataSets' => null !== $this->previousDataSets ? $this->previousDataSets->toArray() : null, - 'QueuedForProcessingDate' => null !== $this->queuedForProcessingDate ? $this->queuedForProcessingDate->toDateTime() : null, + 'PreviousDataSets' => $this->previousDataSets?->toArray(), + 'QueuedForProcessingDate' => $this->queuedForProcessingDate?->toDateTime(), ]; } } diff --git a/src/DTO/BrightspaceDataSet/DataSetReportInfo.php b/src/DTO/BrightspaceDataSet/DataSetReportInfo.php index bef12db..57e70a5 100644 --- a/src/DTO/BrightspaceDataSet/DataSetReportInfo.php +++ b/src/DTO/BrightspaceDataSet/DataSetReportInfo.php @@ -16,11 +16,10 @@ public function __construct( private string $pluginId, private string $name, private string $description, - private ?CarbonImmutable $createdAt, - private ?string $downloadLink, - private ?float $downloadSize - ) { - } + private CarbonImmutable|null $createdAt, + private string|null $downloadLink, + private float|null $downloadSize + ) {} public function getPluginId(): string { @@ -37,17 +36,17 @@ public function getDescription(): string return $this->description; } - public function getCreatedAt(): ?CarbonImmutable + public function getCreatedAt(): CarbonImmutable|null { return $this->createdAt; } - public function getDownloadLink(): ?string + public function getDownloadLink(): string|null { return $this->downloadLink; } - public function getDownloadSize(): ?float + public function getDownloadSize(): float|null { return $this->downloadSize; } @@ -58,7 +57,7 @@ public function toArray(): array 'PluginId' => $this->pluginId, 'Name' => $this->name, 'Description' => $this->description, - 'CreatedDate' => $this->createdAt ? $this->createdAt->toDateTime() : null, + 'CreatedDate' => $this->createdAt?->toDateTime(), 'DownloadLink' => $this->downloadLink, 'DownloadSize' => $this->downloadSize, ]; diff --git a/src/DTO/BrightspaceDataSet/PagedBrightspaceDataSetReportInfo.php b/src/DTO/BrightspaceDataSet/PagedBrightspaceDataSetReportInfo.php index 69598e7..622aaf0 100644 --- a/src/DTO/BrightspaceDataSet/PagedBrightspaceDataSetReportInfo.php +++ b/src/DTO/BrightspaceDataSet/PagedBrightspaceDataSetReportInfo.php @@ -14,23 +14,22 @@ final class PagedBrightspaceDataSetReportInfo implements Arrayable { public function __construct( private Collection $brightspaceDataSets, - private ?string $nextPageUrl = null, - private ?string $prevPageUrl = null - ) { - } + private string|null $nextPageUrl = null, + private string|null $prevPageUrl = null + ) {} - public function getNextPageUrl(): ?string + public function getNextPageUrl(): string|null { return $this->nextPageUrl; } - public function getPrevPageUrl(): ?string + public function getPrevPageUrl(): string|null { return $this->prevPageUrl; } /** - * @return Collection|BrightspaceDataSetReportInfo[] + * @return Collection */ public function getBrightspaceDataSets(): Collection { diff --git a/src/DTO/ContentCompletions/ContentTopicCompletionUpdate.php b/src/DTO/ContentCompletions/ContentTopicCompletionUpdate.php index e0abf0d..20192a1 100644 --- a/src/DTO/ContentCompletions/ContentTopicCompletionUpdate.php +++ b/src/DTO/ContentCompletions/ContentTopicCompletionUpdate.php @@ -12,11 +12,9 @@ */ final class ContentTopicCompletionUpdate { - public function __construct(private ?CarbonImmutable $completedDate) - { - } + public function __construct(private CarbonImmutable|null $completedDate) {} - public function getCompletedDate(): ?CarbonImmutable + public function getCompletedDate(): CarbonImmutable|null { return $this->completedDate; } diff --git a/src/DTO/ContentObject/ContentObject.php b/src/DTO/ContentObject/ContentObject.php index 0fd0773..bb16736 100644 --- a/src/DTO/ContentObject/ContentObject.php +++ b/src/DTO/ContentObject/ContentObject.php @@ -14,18 +14,17 @@ abstract class ContentObject implements Arrayable public function __construct( private int $id, private Type $type, - private ?CarbonImmutable $startDate, - private ?CarbonImmutable $endDate, - private ?CarbonImmutable $dueDate, + private CarbonImmutable|null $startDate, + private CarbonImmutable|null $endDate, + private CarbonImmutable|null $dueDate, private bool $isHidden, private bool $isLocked, private string $title, private string $shortTitle, - private ?RichText $description, - private ?int $parentModuleId, - private ?CarbonImmutable $lastModifiedDate - ) { - } + private RichText|null $description, + private int|null $parentModuleId, + private CarbonImmutable|null $lastModifiedDate + ) {} public function getId(): int { @@ -37,17 +36,17 @@ public function getType(): Type return $this->type; } - public function getStartDate(): ?CarbonImmutable + public function getStartDate(): CarbonImmutable|null { return $this->startDate; } - public function getEndDate(): ?CarbonImmutable + public function getEndDate(): CarbonImmutable|null { return $this->endDate; } - public function getDueDate(): ?CarbonImmutable + public function getDueDate(): CarbonImmutable|null { return $this->dueDate; } @@ -72,17 +71,17 @@ public function getShortTitle(): string return $this->shortTitle; } - public function getDescription(): ?RichText + public function getDescription(): RichText|null { return $this->description; } - public function getParentModuleId(): ?int + public function getParentModuleId(): int|null { return $this->parentModuleId; } - public function getLastModifiedDate(): ?CarbonImmutable + public function getLastModifiedDate(): CarbonImmutable|null { return $this->lastModifiedDate; } diff --git a/src/DTO/ContentObject/Module.php b/src/DTO/ContentObject/Module.php index 12e77bf..10bdf55 100644 --- a/src/DTO/ContentObject/Module.php +++ b/src/DTO/ContentObject/Module.php @@ -18,16 +18,16 @@ final class Module extends ContentObject public function __construct( int $id, private Collection $structure, - ?CarbonImmutable $startDate, - ?CarbonImmutable $endDate, - ?CarbonImmutable $dueDate, + CarbonImmutable|null $startDate, + CarbonImmutable|null $endDate, + CarbonImmutable|null $dueDate, bool $isHidden, bool $isLocked, string $title, string $shortTitle, - ?RichText $description, - ?int $parentModuleId, - ?CarbonImmutable $lastModifiedDate + RichText|null $description, + int|null $parentModuleId, + CarbonImmutable|null $lastModifiedDate ) { parent::__construct( $id, @@ -46,7 +46,7 @@ public function __construct( } /** - * @return Collection|Structure[] + * @return Collection */ public function getStructure(): Collection { diff --git a/src/DTO/ContentObject/Structure.php b/src/DTO/ContentObject/Structure.php index 4b4a7ce..14f5967 100644 --- a/src/DTO/ContentObject/Structure.php +++ b/src/DTO/ContentObject/Structure.php @@ -16,9 +16,8 @@ public function __construct( private string $title, private string $shortTitle, private Type $type, - private ?CarbonImmutable $lastModifiedDate - ) { - } + private CarbonImmutable|null $lastModifiedDate + ) {} public function getId(): int { @@ -40,7 +39,7 @@ public function getType(): Type return $this->type; } - public function getLastModifiedDate(): ?CarbonImmutable + public function getLastModifiedDate(): CarbonImmutable|null { return $this->lastModifiedDate; } diff --git a/src/DTO/ContentObject/Topic.php b/src/DTO/ContentObject/Topic.php index 45a1cec..dd03970 100644 --- a/src/DTO/ContentObject/Topic.php +++ b/src/DTO/ContentObject/Topic.php @@ -20,23 +20,23 @@ public function __construct( int $id, private TopicType $topicType, private string $url, - ?CarbonImmutable $startDate, - ?CarbonImmutable $endDate, - ?CarbonImmutable $dueDate, + CarbonImmutable|null $startDate, + CarbonImmutable|null $endDate, + CarbonImmutable|null $dueDate, bool $isHidden, bool $isLocked, - private ?bool $openAsExternalResource, + private bool|null $openAsExternalResource, string $title, string $shortTitle, - ?RichText $description, + RichText|null $description, int $parentModuleId, - private ?string $activityId, + private string|null $activityId, private bool $isExempt, - private ?int $toolId, - private ?int $toolItemId, + private int|null $toolId, + private int|null $toolItemId, private ActivityType $activityType, - private ?int $gradeItemId, - ?CarbonImmutable $lastModifiedDate, + private int|null $gradeItemId, + CarbonImmutable|null $lastModifiedDate, ) { parent::__construct( $id, @@ -64,12 +64,12 @@ public function getUrl(): string return $this->url; } - public function getOpenAsExternalResource(): ?bool + public function getOpenAsExternalResource(): bool|null { return $this->openAsExternalResource; } - public function getActivityId(): ?string + public function getActivityId(): string|null { return $this->activityId; } @@ -79,12 +79,12 @@ public function isExempt(): bool return $this->isExempt; } - public function getToolId(): ?int + public function getToolId(): int|null { return $this->toolId; } - public function getToolItemId(): ?int + public function getToolItemId(): int|null { return $this->toolItemId; } @@ -94,7 +94,7 @@ public function getActivityType(): ActivityType return $this->activityType; } - public function getGradeItemId(): ?int + public function getGradeItemId(): int|null { return $this->gradeItemId; } diff --git a/src/DTO/DataExport/CreateExportJobData.php b/src/DTO/DataExport/CreateExportJobData.php index 0b50868..6030e8c 100644 --- a/src/DTO/DataExport/CreateExportJobData.php +++ b/src/DTO/DataExport/CreateExportJobData.php @@ -22,6 +22,9 @@ final class CreateExportJobData implements Arrayable, Jsonable */ private array $filters; + /** + * @param ExportJobFilter[] $filters + */ public function __construct(string $dataSetId, array $filters) { $this->dataSetId = $dataSetId; diff --git a/src/DTO/DataExport/DataSetData.php b/src/DTO/DataExport/DataSetData.php index 70b2799..36f637b 100644 --- a/src/DTO/DataExport/DataSetData.php +++ b/src/DTO/DataExport/DataSetData.php @@ -17,8 +17,7 @@ public function __construct( private string $description, private string $category, private Collection $filters - ) { - } + ) {} public function getId(): string { @@ -41,7 +40,7 @@ public function getCategory(): string } /** - * @return Collection|DataSetFilter[] + * @return Collection */ public function getFilters(): Collection { diff --git a/src/DTO/DataExport/DataSetFilter.php b/src/DTO/DataExport/DataSetFilter.php index 06d0be8..6b5c533 100644 --- a/src/DTO/DataExport/DataSetFilter.php +++ b/src/DTO/DataExport/DataSetFilter.php @@ -15,10 +15,9 @@ final class DataSetFilter implements Arrayable public function __construct( private string $name, private ExportFilterType $type, - private ?string $description, - private ?string $defaultValue - ) { - } + private string|null $description, + private string|null $defaultValue + ) {} public function getName(): string { @@ -30,12 +29,12 @@ public function getType(): ExportFilterType return $this->type; } - public function getDescription(): ?string + public function getDescription(): string|null { return $this->description; } - public function getDefaultValue(): ?string + public function getDefaultValue(): string|null { return $this->defaultValue; } diff --git a/src/DTO/DataExport/ExportJobData.php b/src/DTO/DataExport/ExportJobData.php index 60c3a1d..8e7d018 100644 --- a/src/DTO/DataExport/ExportJobData.php +++ b/src/DTO/DataExport/ExportJobData.php @@ -20,8 +20,7 @@ public function __construct( private CarbonImmutable $submitDate, private ExportJobStatus $status, private string $category - ) { - } + ) {} public function getExportJobId(): string { diff --git a/src/DTO/DataExport/ExportJobFilter.php b/src/DTO/DataExport/ExportJobFilter.php index 04df4f6..1c42a9a 100644 --- a/src/DTO/DataExport/ExportJobFilter.php +++ b/src/DTO/DataExport/ExportJobFilter.php @@ -54,7 +54,7 @@ public static function roles(Collection $roles): self return new self(self::ROLES_TYPE, $roles->join(',')); } - public static function userId(?int $userId): self + public static function userId(int|null $userId): self { return new self(self::USER_ID_TYPE, (string) $userId); } diff --git a/src/DTO/Enrollment/CreateEnrollment.php b/src/DTO/Enrollment/CreateEnrollment.php index 6985d7d..3caee5e 100644 --- a/src/DTO/Enrollment/CreateEnrollment.php +++ b/src/DTO/Enrollment/CreateEnrollment.php @@ -10,8 +10,7 @@ public function __construct( private int $orgUnitId, private int $userId, private int $roleId - ) { - } + ) {} public function getOrgUnitId(): int { diff --git a/src/DTO/Enrollment/CreateSectionEnrollment.php b/src/DTO/Enrollment/CreateSectionEnrollment.php index 0047228..5888f69 100644 --- a/src/DTO/Enrollment/CreateSectionEnrollment.php +++ b/src/DTO/Enrollment/CreateSectionEnrollment.php @@ -13,8 +13,7 @@ public function __construct( private int $orgUnitId, private int $userId, private int $sectionId - ) { - } + ) {} public function getOrgUnitId(): int { diff --git a/src/DTO/Enrollment/Enrollment.php b/src/DTO/Enrollment/Enrollment.php index 65c144f..a0b95ad 100644 --- a/src/DTO/Enrollment/Enrollment.php +++ b/src/DTO/Enrollment/Enrollment.php @@ -11,8 +11,7 @@ public function __construct( private int $userId, private int $roleId, private bool $isCascading - ) { - } + ) {} public function getOrgUnitId(): int { diff --git a/src/DTO/Enrollment/OrganizationUnitUser.php b/src/DTO/Enrollment/OrganizationUnitUser.php index a3cd8d0..db89773 100644 --- a/src/DTO/Enrollment/OrganizationUnitUser.php +++ b/src/DTO/Enrollment/OrganizationUnitUser.php @@ -15,8 +15,7 @@ final class OrganizationUnitUser implements Arrayable public function __construct( private User $user, private RoleInfo $roleInfo - ) { - } + ) {} public function getUser(): User { diff --git a/src/DTO/Enrollment/RoleInfo.php b/src/DTO/Enrollment/RoleInfo.php index 35fb9e2..6f58b76 100644 --- a/src/DTO/Enrollment/RoleInfo.php +++ b/src/DTO/Enrollment/RoleInfo.php @@ -14,9 +14,8 @@ final class RoleInfo implements Arrayable public function __construct( private int $id, private string $name, - private ?string $code = null - ) { - } + private string|null $code = null + ) {} public function getId(): int { @@ -28,7 +27,7 @@ public function getName(): string return $this->name; } - public function getCode(): ?string + public function getCode(): string|null { return $this->code; } diff --git a/src/DTO/Grade/GradeObject.php b/src/DTO/Grade/GradeObject.php index db0e21b..679463a 100644 --- a/src/DTO/Grade/GradeObject.php +++ b/src/DTO/Grade/GradeObject.php @@ -11,9 +11,7 @@ */ final class GradeObject implements Arrayable { - public function __construct(private string $name) - { - } + public function __construct(private string $name) {} public function getName(): string { diff --git a/src/DTO/Grade/GradeObjectCategory.php b/src/DTO/Grade/GradeObjectCategory.php index f48e112..86b4173 100644 --- a/src/DTO/Grade/GradeObjectCategory.php +++ b/src/DTO/Grade/GradeObjectCategory.php @@ -16,8 +16,7 @@ public function __construct( private int $id, private Collection $grades, private GradeObjectCategoryData $gradeObjectCategoryData - ) { - } + ) {} public function getId(): int { @@ -25,7 +24,7 @@ public function getId(): int } /** - * @return Collection|GradeObject[] + * @return Collection */ public function getGrades(): Collection { @@ -46,8 +45,8 @@ public function toArray(): array 'ShortName' => $this->gradeObjectCategoryData->getShortName(), 'CanExceedMax' => $this->gradeObjectCategoryData->canExceedMax(), 'ExcludeFromFinalGrade' => $this->gradeObjectCategoryData->excludeFromFinalGrade(), - 'StartDate' => $this->gradeObjectCategoryData->getStartDate() ? $this->gradeObjectCategoryData->getStartDate()->toDateTime() : null, - 'EndDate' => $this->gradeObjectCategoryData->getEndDate() ? $this->gradeObjectCategoryData->getEndDate()->toDateTime() : null, + 'StartDate' => $this->gradeObjectCategoryData->getStartDate()?->toDateTime(), + 'EndDate' => $this->gradeObjectCategoryData->getEndDate()?->toDateTime(), 'Weight' => $this->gradeObjectCategoryData->getWeight(), 'MaxPoints' => $this->gradeObjectCategoryData->getMaxPoints(), 'AutoPoints' => $this->gradeObjectCategoryData->autoPoints(), diff --git a/src/DTO/Grade/GradeObjectCategoryData.php b/src/DTO/Grade/GradeObjectCategoryData.php index af2d92b..fc489d1 100644 --- a/src/DTO/Grade/GradeObjectCategoryData.php +++ b/src/DTO/Grade/GradeObjectCategoryData.php @@ -16,16 +16,15 @@ public function __construct( private string $shortName, private bool $canExceedMax, private bool $excludeFromFinalGrade, - private ?CarbonImmutable $startDate, - private ?CarbonImmutable $endDate, - private ?float $weight, - private ?float $maxPoints, - private ?bool $autoPoints, - private ?int $weightDistributionType, - private ?int $numberOfHighestToDrop, - private ?int $numberOfLowestToDrop - ) { - } + private CarbonImmutable|null $startDate, + private CarbonImmutable|null $endDate, + private float|null $weight, + private float|null $maxPoints, + private bool|null $autoPoints, + private int|null $weightDistributionType, + private int|null $numberOfHighestToDrop, + private int|null $numberOfLowestToDrop + ) {} public function getName(): string { @@ -47,42 +46,42 @@ public function excludeFromFinalGrade(): bool return $this->excludeFromFinalGrade; } - public function getStartDate(): ?CarbonImmutable + public function getStartDate(): CarbonImmutable|null { return $this->startDate; } - public function getEndDate(): ?CarbonImmutable + public function getEndDate(): CarbonImmutable|null { return $this->endDate; } - public function getWeight(): ?float + public function getWeight(): float|null { return $this->weight; } - public function getMaxPoints(): ?float + public function getMaxPoints(): float|null { return $this->maxPoints; } - public function autoPoints(): ?bool + public function autoPoints(): bool|null { return $this->autoPoints; } - public function getWeightDistributionType(): ?int + public function getWeightDistributionType(): int|null { return $this->weightDistributionType; } - public function getNumberOfHighestToDrop(): ?int + public function getNumberOfHighestToDrop(): int|null { return $this->numberOfHighestToDrop; } - public function getNumberOfLowestToDrop(): ?int + public function getNumberOfLowestToDrop(): int|null { return $this->numberOfLowestToDrop; } diff --git a/src/DTO/Grade/IncomingGradeValue.php b/src/DTO/Grade/IncomingGradeValue.php index 66af255..dce8ae7 100644 --- a/src/DTO/Grade/IncomingGradeValue.php +++ b/src/DTO/Grade/IncomingGradeValue.php @@ -146,10 +146,9 @@ private function __construct( private RichTextInput $comments, private RichTextInput $privateComments, private GradeObjectType $gradeObjectType, - private ?float $pointsNumerator = null, - private ?bool $pass = null, - private ?string $value = null, - private ?string $text = null, - ) { - } + private float|null $pointsNumerator = null, + private bool|null $pass = null, + private string|null $value = null, + private string|null $text = null, + ) {} } diff --git a/src/DTO/Guid.php b/src/DTO/Guid.php index 9c574a3..15331f1 100644 --- a/src/DTO/Guid.php +++ b/src/DTO/Guid.php @@ -6,9 +6,7 @@ final class Guid { - public function __construct(private string $value) - { - } + public function __construct(private string $value) {} public function getValue(): string { diff --git a/src/DTO/ObjectListPage.php b/src/DTO/ObjectListPage.php index 8f22301..ea5a53d 100644 --- a/src/DTO/ObjectListPage.php +++ b/src/DTO/ObjectListPage.php @@ -9,13 +9,13 @@ abstract class ObjectListPage { public function __construct( - private ?string $nextUrl, + private string|null $nextUrl, private Collection $objects ) { $this->checkObjectInstance(); } - public function getNextUrl(): ?string + public function getNextUrl(): string|null { return $this->nextUrl; } diff --git a/src/DTO/Organization/OrgUnit.php b/src/DTO/Organization/OrgUnit.php index 677cac8..80edcdc 100644 --- a/src/DTO/Organization/OrgUnit.php +++ b/src/DTO/Organization/OrgUnit.php @@ -15,9 +15,8 @@ public function __construct( private string $identifier, private string $name, private OrganizationUnitTypeInfo $organizationUnitTypeInfo, - private ?string $code = null - ) { - } + private string|null $code = null + ) {} public function getIdentifier(): string { @@ -34,7 +33,7 @@ public function getOrganizationUnitTypeInfo(): OrganizationUnitTypeInfo return $this->organizationUnitTypeInfo; } - public function getCode(): ?string + public function getCode(): string|null { return $this->code; } diff --git a/src/DTO/Organization/OrgUnitProperties.php b/src/DTO/Organization/OrgUnitProperties.php index 5ccf05a..247edc2 100644 --- a/src/DTO/Organization/OrgUnitProperties.php +++ b/src/DTO/Organization/OrgUnitProperties.php @@ -16,9 +16,8 @@ public function __construct( private string $name, private OrganizationUnitTypeInfo $organizationUnitTypeInfo, private string $path, - private ?string $code = null - ) { - } + private string|null $code = null + ) {} public function getIdentifier(): string { @@ -40,7 +39,7 @@ public function getPath(): string return $this->path; } - public function getCode(): ?string + public function getCode(): string|null { return $this->code; } diff --git a/src/DTO/Organization/OrganizationInfo.php b/src/DTO/Organization/OrganizationInfo.php index 0b750e7..7106c19 100644 --- a/src/DTO/Organization/OrganizationInfo.php +++ b/src/DTO/Organization/OrganizationInfo.php @@ -15,8 +15,7 @@ public function __construct( private string $identifier, private string $name, private string $timeZone - ) { - } + ) {} public function getIdentifier(): string { diff --git a/src/DTO/Organization/OrganizationUnitTypeInfo.php b/src/DTO/Organization/OrganizationUnitTypeInfo.php index e49666b..7af263e 100644 --- a/src/DTO/Organization/OrganizationUnitTypeInfo.php +++ b/src/DTO/Organization/OrganizationUnitTypeInfo.php @@ -15,8 +15,7 @@ public function __construct( private int $id, private string $code, private string $name - ) { - } + ) {} public function getId(): int { diff --git a/src/DTO/Quiz/AttemptsAllowed.php b/src/DTO/Quiz/AttemptsAllowed.php index 115eeea..f0a1b5e 100644 --- a/src/DTO/Quiz/AttemptsAllowed.php +++ b/src/DTO/Quiz/AttemptsAllowed.php @@ -10,16 +10,15 @@ final class AttemptsAllowed implements Arrayable { public function __construct( private bool $isUnlimited, - private ?int $numberOfAttemptsAllowed - ) { - } + private int|null $numberOfAttemptsAllowed + ) {} public function isUnlimited(): bool { return $this->isUnlimited; } - public function getNumberOfAttemptsAllowed(): ?int + public function getNumberOfAttemptsAllowed(): int|null { return $this->numberOfAttemptsAllowed; } diff --git a/src/DTO/Quiz/Description.php b/src/DTO/Quiz/Description.php index a877888..fece062 100644 --- a/src/DTO/Quiz/Description.php +++ b/src/DTO/Quiz/Description.php @@ -12,8 +12,7 @@ final class Description implements Arrayable public function __construct( private RichText $text, private bool $isDisplayed - ) { - } + ) {} public function getText(): RichText { diff --git a/src/DTO/Quiz/FillInTheBlank.php b/src/DTO/Quiz/FillInTheBlank.php index d239ce4..3a8a6c1 100644 --- a/src/DTO/Quiz/FillInTheBlank.php +++ b/src/DTO/Quiz/FillInTheBlank.php @@ -14,11 +14,10 @@ final class FillInTheBlank implements QuestionInfo public function __construct( private Collection $texts, private Collection $blanks - ) { - } + ) {} /** - * @return Collection|FillInTheBlankText[] + * @return Collection */ public function getTexts(): Collection { @@ -26,7 +25,7 @@ public function getTexts(): Collection } /** - * @return Collection|FillInTheBlankBlank[] + * @return Collection */ public function getBlanks(): Collection { diff --git a/src/DTO/Quiz/FillInTheBlankAnswer.php b/src/DTO/Quiz/FillInTheBlankAnswer.php index 56cdab4..1290b81 100644 --- a/src/DTO/Quiz/FillInTheBlankAnswer.php +++ b/src/DTO/Quiz/FillInTheBlankAnswer.php @@ -13,8 +13,7 @@ public function __construct( private string $textAnswer, private float $weight, private EvaluationType $evaluationType - ) { - } + ) {} public function getTextAnswer(): string { diff --git a/src/DTO/Quiz/FillInTheBlankBlank.php b/src/DTO/Quiz/FillInTheBlankBlank.php index c3eac65..f6991dc 100644 --- a/src/DTO/Quiz/FillInTheBlankBlank.php +++ b/src/DTO/Quiz/FillInTheBlankBlank.php @@ -13,8 +13,7 @@ public function __construct( private int $partId, private int $size, private Collection $answers - ) { - } + ) {} public function getPartId(): int { @@ -27,7 +26,7 @@ public function getSize(): int } /** - * @return Collection|FillInTheBlankAnswer[] + * @return Collection */ public function getAnswers(): Collection { diff --git a/src/DTO/Quiz/FillInTheBlankText.php b/src/DTO/Quiz/FillInTheBlankText.php index a6ce737..b3ea0b5 100644 --- a/src/DTO/Quiz/FillInTheBlankText.php +++ b/src/DTO/Quiz/FillInTheBlankText.php @@ -9,9 +9,7 @@ final class FillInTheBlankText implements Arrayable { - public function __construct(private RichText $text) - { - } + public function __construct(private RichText $text) {} public function getText(): RichText { diff --git a/src/DTO/Quiz/Footer.php b/src/DTO/Quiz/Footer.php index 2f87bd1..277ae64 100644 --- a/src/DTO/Quiz/Footer.php +++ b/src/DTO/Quiz/Footer.php @@ -12,8 +12,7 @@ final class Footer implements Arrayable public function __construct( private RichText $text, private bool $isDisplayed - ) { - } + ) {} public function getText(): RichText { diff --git a/src/DTO/Quiz/Header.php b/src/DTO/Quiz/Header.php index 4cd0d89..6ae3522 100644 --- a/src/DTO/Quiz/Header.php +++ b/src/DTO/Quiz/Header.php @@ -12,8 +12,7 @@ final class Header implements Arrayable public function __construct( private RichText $text, private bool $isDisplayed - ) { - } + ) {} public function getText(): RichText { diff --git a/src/DTO/Quiz/Instructions.php b/src/DTO/Quiz/Instructions.php index 12152ee..e222093 100644 --- a/src/DTO/Quiz/Instructions.php +++ b/src/DTO/Quiz/Instructions.php @@ -12,8 +12,7 @@ final class Instructions implements Arrayable public function __construct( private RichText $text, private bool $isDisplayed - ) { - } + ) {} public function getText(): RichText { diff --git a/src/DTO/Quiz/LateSubmissionInfo.php b/src/DTO/Quiz/LateSubmissionInfo.php index bd2971f..ac0f9c3 100644 --- a/src/DTO/Quiz/LateSubmissionInfo.php +++ b/src/DTO/Quiz/LateSubmissionInfo.php @@ -11,16 +11,15 @@ final class LateSubmissionInfo implements Arrayable { public function __construct( private LateSubmissionOption $lateSubmissionOption, - private ?int $lateLimitMinutes - ) { - } + private int|null $lateLimitMinutes + ) {} public function getLateSubmissionOption(): LateSubmissionOption { return $this->lateSubmissionOption; } - public function getLateLimitMinutes(): ?int + public function getLateLimitMinutes(): int|null { return $this->lateLimitMinutes; } diff --git a/src/DTO/Quiz/Likert.php b/src/DTO/Quiz/Likert.php index 6f3faf7..4aeacac 100644 --- a/src/DTO/Quiz/Likert.php +++ b/src/DTO/Quiz/Likert.php @@ -16,8 +16,7 @@ public function __construct( private QuestionScaleOption $scale, private bool $naOption, private Collection $statements, - ) { - } + ) {} public function getScale(): QuestionScaleOption { @@ -30,7 +29,7 @@ public function isNaOption(): bool } /** - * @return Collection|LikertStatement[] + * @return Collection */ public function getStatements(): Collection { diff --git a/src/DTO/Quiz/LikertStatement.php b/src/DTO/Quiz/LikertStatement.php index d667939..48363a8 100644 --- a/src/DTO/Quiz/LikertStatement.php +++ b/src/DTO/Quiz/LikertStatement.php @@ -12,8 +12,7 @@ final class LikertStatement implements Arrayable public function __construct( private int $partId, private RichText $statement, - ) { - } + ) {} public function getPartId(): int { diff --git a/src/DTO/Quiz/LongAnswer.php b/src/DTO/Quiz/LongAnswer.php index d098d05..2c55ece 100644 --- a/src/DTO/Quiz/LongAnswer.php +++ b/src/DTO/Quiz/LongAnswer.php @@ -16,9 +16,8 @@ public function __construct( private bool $studentEditorEnabled, private RichText $initialText, private RichText $answerKey, - private ?bool $attachmentsEnabled, - ) { - } + private bool|null $attachmentsEnabled, + ) {} public function getPartId(): int { @@ -40,7 +39,7 @@ public function getAnswerKey(): RichText return $this->answerKey; } - public function attachmentsEnabled(): ?bool + public function attachmentsEnabled(): bool|null { return $this->attachmentsEnabled; } diff --git a/src/DTO/Quiz/MultiSelectAnswer.php b/src/DTO/Quiz/MultiSelectAnswer.php index 9aa4df6..cded3eb 100644 --- a/src/DTO/Quiz/MultiSelectAnswer.php +++ b/src/DTO/Quiz/MultiSelectAnswer.php @@ -14,8 +14,7 @@ public function __construct( private RichText $answer, private RichText $answerFeedback, private bool $isCorrect, - ) { - } + ) {} public function getPartId(): int { diff --git a/src/DTO/Quiz/MultiSelectAnswers.php b/src/DTO/Quiz/MultiSelectAnswers.php index 9985b3d..ee5e5c5 100644 --- a/src/DTO/Quiz/MultiSelectAnswers.php +++ b/src/DTO/Quiz/MultiSelectAnswers.php @@ -20,11 +20,10 @@ public function __construct( private EnumerationType $enumeration, private QuestionStyle $style, private QuestionGradingRule $gradingType, - ) { - } + ) {} /** - * @return Collection|MultiSelectAnswer[] + * @return Collection */ public function getAnswers(): Collection { diff --git a/src/DTO/Quiz/MultipleChoiceAnswer.php b/src/DTO/Quiz/MultipleChoiceAnswer.php index 33c9a2c..d04a1cd 100644 --- a/src/DTO/Quiz/MultipleChoiceAnswer.php +++ b/src/DTO/Quiz/MultipleChoiceAnswer.php @@ -17,8 +17,7 @@ public function __construct( private RichText $answer, private RichText $answerFeedback, private float $weight, - ) { - } + ) {} public function getPartId(): int { diff --git a/src/DTO/Quiz/MultipleChoiceAnswers.php b/src/DTO/Quiz/MultipleChoiceAnswers.php index d91f53f..2fa417c 100644 --- a/src/DTO/Quiz/MultipleChoiceAnswers.php +++ b/src/DTO/Quiz/MultipleChoiceAnswers.php @@ -16,11 +16,10 @@ public function __construct( private Collection $answers, private bool $randomize, private EnumerationType $enumeration, - ) { - } + ) {} /** - * @return Collection|MultipleChoiceAnswer[] + * @return Collection */ public function getAnswers(): Collection { diff --git a/src/DTO/Quiz/MultipleShortAnswer.php b/src/DTO/Quiz/MultipleShortAnswer.php index 7e8670b..baef1b7 100644 --- a/src/DTO/Quiz/MultipleShortAnswer.php +++ b/src/DTO/Quiz/MultipleShortAnswer.php @@ -13,8 +13,7 @@ public function __construct( private string $answerText, private float $weight, private EvaluationType $evaluationType, - ) { - } + ) {} public function getAnswerText(): string { diff --git a/src/DTO/Quiz/MultipleShortAnswers.php b/src/DTO/Quiz/MultipleShortAnswers.php index a2b82a9..62a7dd1 100644 --- a/src/DTO/Quiz/MultipleShortAnswers.php +++ b/src/DTO/Quiz/MultipleShortAnswers.php @@ -17,11 +17,10 @@ public function __construct( private int $rows, private int $columns, private Collection $answers - ) { - } + ) {} /** - * @return Collection|int[] + * @return Collection */ public function getPartIds(): Collection { @@ -44,7 +43,7 @@ public function getColumns(): int } /** - * @return Collection|MultipleShortAnswer[] + * @return Collection */ public function getAnswers(): Collection { diff --git a/src/DTO/Quiz/QuestionInfo.php b/src/DTO/Quiz/QuestionInfo.php index d4a5e9f..3e18940 100644 --- a/src/DTO/Quiz/QuestionInfo.php +++ b/src/DTO/Quiz/QuestionInfo.php @@ -9,6 +9,4 @@ /** * @link https://docs.valence.desire2learn.com/res/quiz.html#Question.QuestionInfo */ -interface QuestionInfo extends Arrayable -{ -} +interface QuestionInfo extends Arrayable {} diff --git a/src/DTO/Quiz/Quiz.php b/src/DTO/Quiz/Quiz.php index 8429ede..14cac64 100644 --- a/src/DTO/Quiz/Quiz.php +++ b/src/DTO/Quiz/Quiz.php @@ -20,36 +20,35 @@ public function __construct( private string $name, private bool $isActive, private int $sortOrder, - private ?bool $autoExportToGrades, - private ?int $gradeItemId, + private bool|null $autoExportToGrades, + private int|null $gradeItemId, private bool $isAutoSetGraded, private Instructions $instructions, private Description $description, - private ?CarbonImmutable $startDate, - private ?CarbonImmutable $endDate, - private ?CarbonImmutable $dueDate, + private CarbonImmutable|null $startDate, + private CarbonImmutable|null $endDate, + private CarbonImmutable|null $dueDate, private bool $displayInCalendar, private AttemptsAllowed $attemptsAllowed, private LateSubmissionInfo $lateSubmissionInfo, private SubmissionTimeLimit $submissionTimeLimit, - private ?int $submissionGracePeriod, - private ?string $password, + private int|null $submissionGracePeriod, + private string|null $password, private Header $header, private Footer $footer, private bool $allowHints, private bool $disableRightClick, private bool $disablePagerAndAlerts, - private ?string $notificationEmail, + private string|null $notificationEmail, private OverallGradeCalculationOption $calcTypeId, private Collection $restrictIPAddressRange, - private ?int $categoryId, + private int|null $categoryId, private bool $preventMovingBackwards, private bool $shuffle, - private ?string $activityId, + private string|null $activityId, private bool $allowOnlyUsersWithSpecialAccess, private bool $isRetakeIncorrectOnly, - ) { - } + ) {} public function getId(): int { @@ -71,12 +70,12 @@ public function getSortOrder(): int return $this->sortOrder; } - public function getAutoExportToGrades(): ?bool + public function getAutoExportToGrades(): bool|null { return $this->autoExportToGrades; } - public function getGradeItemId(): ?int + public function getGradeItemId(): int|null { return $this->gradeItemId; } @@ -96,17 +95,17 @@ public function getDescription(): Description return $this->description; } - public function getStartDate(): ?CarbonImmutable + public function getStartDate(): CarbonImmutable|null { return $this->startDate; } - public function getEndDate(): ?CarbonImmutable + public function getEndDate(): CarbonImmutable|null { return $this->endDate; } - public function getDueDate(): ?CarbonImmutable + public function getDueDate(): CarbonImmutable|null { return $this->dueDate; } @@ -131,12 +130,12 @@ public function getSubmissionTimeLimit(): SubmissionTimeLimit return $this->submissionTimeLimit; } - public function getSubmissionGracePeriod(): ?int + public function getSubmissionGracePeriod(): int|null { return $this->submissionGracePeriod; } - public function getPassword(): ?string + public function getPassword(): string|null { return $this->password; } @@ -166,7 +165,7 @@ public function disablePagerAndAlerts(): bool return $this->disablePagerAndAlerts; } - public function getNotificationEmail(): ?string + public function getNotificationEmail(): string|null { return $this->notificationEmail; } @@ -177,14 +176,14 @@ public function getCalcTypeId(): OverallGradeCalculationOption } /** - * @return Collection|RestrictIPAddressRange[] + * @return Collection */ public function getRestrictIPAddressRange(): Collection { return $this->restrictIPAddressRange; } - public function getCategoryId(): ?int + public function getCategoryId(): int|null { return $this->categoryId; } @@ -199,7 +198,7 @@ public function shuffle(): bool return $this->shuffle; } - public function getActivityId(): ?string + public function getActivityId(): string|null { return $this->activityId; } diff --git a/src/DTO/Quiz/QuizListPage.php b/src/DTO/Quiz/QuizListPage.php index f3dfcaf..cfbc7f2 100644 --- a/src/DTO/Quiz/QuizListPage.php +++ b/src/DTO/Quiz/QuizListPage.php @@ -8,7 +8,7 @@ use Petersons\D2L\DTO\ObjectListPage; /** - * @method Collection|Quiz[] getObjects + * @method Collection getObjects */ final class QuizListPage extends ObjectListPage { diff --git a/src/DTO/Quiz/QuizQuestion.php b/src/DTO/Quiz/QuizQuestion.php index 22d29df..062a9a7 100644 --- a/src/DTO/Quiz/QuizQuestion.php +++ b/src/DTO/Quiz/QuizQuestion.php @@ -17,22 +17,21 @@ final class QuizQuestion implements Arrayable public function __construct( private int $id, private QuizQuestionType $type, - private ?string $name, + private string|null $name, private RichText $text, private float $points, private int $difficulty, private bool $isBonus, private bool $isMandatory, - private ?RichText $hint, - private ?RichText $feedback, + private RichText|null $hint, + private RichText|null $feedback, private CarbonImmutable $lastModifiedAt, - private ?int $lastModifiedBy, + private int|null $lastModifiedBy, private int $sectionId, private int $templateId, private int $templateVersionId, - private ?QuestionInfo $questionInfo, - ) { - } + private QuestionInfo|null $questionInfo, + ) {} public function getId(): int { @@ -44,7 +43,7 @@ public function getType(): QuizQuestionType return $this->type; } - public function getName(): ?string + public function getName(): string|null { return $this->name; } @@ -74,12 +73,12 @@ public function isMandatory(): bool return $this->isMandatory; } - public function getHint(): ?RichText + public function getHint(): RichText|null { return $this->hint; } - public function getFeedback(): ?RichText + public function getFeedback(): RichText|null { return $this->feedback; } @@ -89,7 +88,7 @@ public function getLastModifiedAt(): CarbonImmutable return $this->lastModifiedAt; } - public function getLastModifiedBy(): ?int + public function getLastModifiedBy(): int|null { return $this->lastModifiedBy; } @@ -109,7 +108,7 @@ public function getTemplateVersionId(): int return $this->templateVersionId; } - public function getQuestionInfo(): ?QuestionInfo + public function getQuestionInfo(): QuestionInfo|null { return $this->questionInfo; } diff --git a/src/DTO/Quiz/QuizQuestionListPage.php b/src/DTO/Quiz/QuizQuestionListPage.php index b1176d5..72217a7 100644 --- a/src/DTO/Quiz/QuizQuestionListPage.php +++ b/src/DTO/Quiz/QuizQuestionListPage.php @@ -8,7 +8,7 @@ use Petersons\D2L\DTO\ObjectListPage; /** - * @method Collection|QuizQuestion[] getObjects + * @method Collection getObjects */ final class QuizQuestionListPage extends ObjectListPage { diff --git a/src/DTO/Quiz/RestrictIPAddressRange.php b/src/DTO/Quiz/RestrictIPAddressRange.php index 79802af..3e38a62 100644 --- a/src/DTO/Quiz/RestrictIPAddressRange.php +++ b/src/DTO/Quiz/RestrictIPAddressRange.php @@ -10,16 +10,15 @@ final class RestrictIPAddressRange implements Arrayable { public function __construct( private string $IPRangeStart, - private ?string $IPRangeEnd - ) { - } + private string|null $IPRangeEnd + ) {} public function getIPRangeStart(): string { return $this->IPRangeStart; } - public function getIPRangeEnd(): ?string + public function getIPRangeEnd(): string|null { return $this->IPRangeEnd; } diff --git a/src/DTO/Quiz/ShortAnswerBlank.php b/src/DTO/Quiz/ShortAnswerBlank.php index e86fc0c..9a7ae55 100644 --- a/src/DTO/Quiz/ShortAnswerBlank.php +++ b/src/DTO/Quiz/ShortAnswerBlank.php @@ -17,8 +17,7 @@ public function __construct( private int $partId, private Collection $answers, private EvaluationType $evaluationType, - ) { - } + ) {} public function getPartId(): int { @@ -26,7 +25,7 @@ public function getPartId(): int } /** - * @return Collection|ShortAnswerBlankAnswer[] + * @return Collection */ public function getAnswers(): Collection { diff --git a/src/DTO/Quiz/ShortAnswerBlankAnswer.php b/src/DTO/Quiz/ShortAnswerBlankAnswer.php index 168e0d5..9888c9b 100644 --- a/src/DTO/Quiz/ShortAnswerBlankAnswer.php +++ b/src/DTO/Quiz/ShortAnswerBlankAnswer.php @@ -11,8 +11,7 @@ final class ShortAnswerBlankAnswer implements Arrayable public function __construct( private string $text, private float $weight - ) { - } + ) {} public function getText(): string { diff --git a/src/DTO/Quiz/ShortAnswers.php b/src/DTO/Quiz/ShortAnswers.php index 729dcd4..7843974 100644 --- a/src/DTO/Quiz/ShortAnswers.php +++ b/src/DTO/Quiz/ShortAnswers.php @@ -15,11 +15,10 @@ final class ShortAnswers implements QuestionInfo public function __construct( private Collection $blanks, private QuestionGradingRule $gradingType, - ) { - } + ) {} /** - * @return Collection|ShortAnswerBlank[] + * @return Collection */ public function getBlanks(): Collection { diff --git a/src/DTO/Quiz/SubmissionTimeLimit.php b/src/DTO/Quiz/SubmissionTimeLimit.php index 235b59f..3629b95 100644 --- a/src/DTO/Quiz/SubmissionTimeLimit.php +++ b/src/DTO/Quiz/SubmissionTimeLimit.php @@ -12,8 +12,7 @@ public function __construct( private bool $isEnforced, private bool $showClock, private int $timeLimitValue - ) { - } + ) {} public function isEnforced(): bool { diff --git a/src/DTO/Quiz/TrueFalse.php b/src/DTO/Quiz/TrueFalse.php index 68250d1..70e247b 100644 --- a/src/DTO/Quiz/TrueFalse.php +++ b/src/DTO/Quiz/TrueFalse.php @@ -20,8 +20,7 @@ public function __construct( private float $falseWeight, private RichText $falseFeedback, private EnumerationType $enumeration, - ) { - } + ) {} public function getTruePartId(): int { diff --git a/src/DTO/RichText.php b/src/DTO/RichText.php index 4f841f9..91ce7f9 100644 --- a/src/DTO/RichText.php +++ b/src/DTO/RichText.php @@ -13,16 +13,15 @@ final class RichText implements Arrayable { public function __construct( private string $text, - private ?string $html - ) { - } + private string|null $html + ) {} public function getText(): string { return $this->text; } - public function getHtml(): ?string + public function getHtml(): string|null { return $this->html; } diff --git a/src/DTO/RichTextInput.php b/src/DTO/RichTextInput.php index 03bbde1..da4eef2 100644 --- a/src/DTO/RichTextInput.php +++ b/src/DTO/RichTextInput.php @@ -15,8 +15,7 @@ final class RichTextInput implements Arrayable public function __construct( private string $content, private RichTextInputType $richTextInputType, - ) { - } + ) {} public function getContent(): string { diff --git a/src/DTO/Section/Section.php b/src/DTO/Section/Section.php index 850963b..520b041 100644 --- a/src/DTO/Section/Section.php +++ b/src/DTO/Section/Section.php @@ -18,8 +18,7 @@ public function __construct( private string $code, private RichText $description, private array $enrollments, - ) { - } + ) {} public function getSectionId(): int { diff --git a/src/DTO/User/CreateUser.php b/src/DTO/User/CreateUser.php index 3eebdcd..4f5148f 100644 --- a/src/DTO/User/CreateUser.php +++ b/src/DTO/User/CreateUser.php @@ -12,15 +12,14 @@ final class CreateUser public function __construct( private string $orgDefinedId, private string $firstName, - private ?string $middleName, + private string|null $middleName, private string $lastName, - private ?string $externalEmail, + private string|null $externalEmail, private string $username, private int $roleId, private bool $isActive, private bool $sendCreationEmail - ) { - } + ) {} public function getOrgDefinedId(): string { @@ -32,7 +31,7 @@ public function getFirstName(): string return $this->firstName; } - public function getMiddleName(): ?string + public function getMiddleName(): string|null { return $this->middleName; } @@ -42,7 +41,7 @@ public function getLastName(): string return $this->lastName; } - public function getExternalEmail(): ?string + public function getExternalEmail(): string|null { return $this->externalEmail; } diff --git a/src/DTO/User/UpdateUser.php b/src/DTO/User/UpdateUser.php index 115c401..180febd 100644 --- a/src/DTO/User/UpdateUser.php +++ b/src/DTO/User/UpdateUser.php @@ -13,13 +13,12 @@ public function __construct( private int $lmsUserId, private string $orgDefinedId, private string $firstName, - private ?string $middleName, + private string|null $middleName, private string $lastName, - private ?string $externalEmail, + private string|null $externalEmail, private string $userName, private bool $isActive - ) { - } + ) {} public function getLmsUserId(): int { @@ -36,7 +35,7 @@ public function getFirstName(): string return $this->firstName; } - public function getMiddleName(): ?string + public function getMiddleName(): string|null { return $this->middleName; } @@ -46,7 +45,7 @@ public function getLastName(): string return $this->lastName; } - public function getExternalEmail(): ?string + public function getExternalEmail(): string|null { return $this->externalEmail; } diff --git a/src/DTO/User/User.php b/src/DTO/User/User.php index 6ac664a..d2ff98f 100644 --- a/src/DTO/User/User.php +++ b/src/DTO/User/User.php @@ -12,41 +12,40 @@ final class User implements Arrayable { public function __construct( - private ?string $identifier = null, - private ?string $displayName = null, - private ?string $emailAddress = null, - private ?string $orgDefinedId = null, - private ?string $profileBadgeUrl = null, - private ?string $profileIdentifier = null - ) { - } + private string|null $identifier = null, + private string|null $displayName = null, + private string|null $emailAddress = null, + private string|null $orgDefinedId = null, + private string|null $profileBadgeUrl = null, + private string|null $profileIdentifier = null + ) {} - public function getIdentifier(): ?string + public function getIdentifier(): string|null { return $this->identifier; } - public function getDisplayName(): ?string + public function getDisplayName(): string|null { return $this->displayName; } - public function getEmailAddress(): ?string + public function getEmailAddress(): string|null { return $this->emailAddress; } - public function getOrgDefinedId(): ?string + public function getOrgDefinedId(): string|null { return $this->orgDefinedId; } - public function getProfileBadgeUrl(): ?string + public function getProfileBadgeUrl(): string|null { return $this->profileBadgeUrl; } - public function getProfileIdentifier(): ?string + public function getProfileIdentifier(): string|null { return $this->profileIdentifier; } diff --git a/src/DTO/User/UserData.php b/src/DTO/User/UserData.php index e84bc59..d49e5aa 100644 --- a/src/DTO/User/UserData.php +++ b/src/DTO/User/UserData.php @@ -15,16 +15,15 @@ public function __construct( private int $orgId, private int $userId, private string $firstName, - private ?string $middleName, + private string|null $middleName, private string $lastName, private string $username, - private ?string $externalEmail, - private ?string $orgDefinedId, + private string|null $externalEmail, + private string|null $orgDefinedId, private string $uniqueIdentifier, private bool $isActive, - private ?CarbonImmutable $lastAccessedAt - ) { - } + private CarbonImmutable|null $lastAccessedAt + ) {} public function getOrgId(): int { @@ -41,7 +40,7 @@ public function getFirstName(): string return $this->firstName; } - public function getMiddleName(): ?string + public function getMiddleName(): string|null { return $this->middleName; } @@ -56,12 +55,12 @@ public function getUsername(): string return $this->username; } - public function getExternalEmail(): ?string + public function getExternalEmail(): string|null { return $this->externalEmail; } - public function getOrgDefinedId(): ?string + public function getOrgDefinedId(): string|null { return $this->orgDefinedId; } @@ -76,7 +75,7 @@ public function isActive(): bool return $this->isActive; } - public function getLastAccessedAt(): ?CarbonImmutable + public function getLastAccessedAt(): CarbonImmutable|null { return $this->lastAccessedAt; } diff --git a/src/Enum/ContentObject/ActivityType.php b/src/Enum/ContentObject/ActivityType.php index e39d76b..7853f6c 100644 --- a/src/Enum/ContentObject/ActivityType.php +++ b/src/Enum/ContentObject/ActivityType.php @@ -62,7 +62,5 @@ public function getType(): int return $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/ContentObject/TopicType.php b/src/Enum/ContentObject/TopicType.php index 01b0ca3..b93718e 100644 --- a/src/Enum/ContentObject/TopicType.php +++ b/src/Enum/ContentObject/TopicType.php @@ -36,7 +36,5 @@ public function getType(): int return $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/ContentObject/Type.php b/src/Enum/ContentObject/Type.php index 37515f8..791ea17 100644 --- a/src/Enum/ContentObject/Type.php +++ b/src/Enum/ContentObject/Type.php @@ -48,7 +48,5 @@ public function getType(): int return $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/DataExport/ExportFilterType.php b/src/Enum/DataExport/ExportFilterType.php index 89addc8..5f7efc5 100644 --- a/src/Enum/DataExport/ExportFilterType.php +++ b/src/Enum/DataExport/ExportFilterType.php @@ -34,7 +34,5 @@ public function __toString(): string return (string) $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/Grade/GradeObjectType.php b/src/Enum/Grade/GradeObjectType.php index dd41b86..f0e5047 100644 --- a/src/Enum/Grade/GradeObjectType.php +++ b/src/Enum/Grade/GradeObjectType.php @@ -87,7 +87,5 @@ public function isCategory(): bool return self::CATEGORY === $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/Quiz/EnumerationType.php b/src/Enum/Quiz/EnumerationType.php index 820c1be..d806929 100644 --- a/src/Enum/Quiz/EnumerationType.php +++ b/src/Enum/Quiz/EnumerationType.php @@ -36,7 +36,5 @@ public function type(): int return $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/Quiz/EvaluationType.php b/src/Enum/Quiz/EvaluationType.php index 657fb8a..1f76b78 100644 --- a/src/Enum/Quiz/EvaluationType.php +++ b/src/Enum/Quiz/EvaluationType.php @@ -30,7 +30,5 @@ public function type(): int return $this->type; } - private function __construct(private int $type) - { - } + private function __construct(private int $type) {} } diff --git a/src/Enum/Quiz/LateSubmissionOption.php b/src/Enum/Quiz/LateSubmissionOption.php index 673f3c9..fa6c1b4 100644 --- a/src/Enum/Quiz/LateSubmissionOption.php +++ b/src/Enum/Quiz/LateSubmissionOption.php @@ -30,7 +30,5 @@ public function getOption(): int return $this->option; } - private function __construct(private int $option) - { - } + private function __construct(private int $option) {} } diff --git a/src/Enum/Quiz/OverallGradeCalculationOption.php b/src/Enum/Quiz/OverallGradeCalculationOption.php index 6e9284c..d08b908 100644 --- a/src/Enum/Quiz/OverallGradeCalculationOption.php +++ b/src/Enum/Quiz/OverallGradeCalculationOption.php @@ -34,7 +34,5 @@ public function getOption(): int return $this->option; } - private function __construct(private int $option) - { - } + private function __construct(private int $option) {} } diff --git a/src/Enum/Quiz/QuestionGradingRule.php b/src/Enum/Quiz/QuestionGradingRule.php index f4f5419..60b67b2 100644 --- a/src/Enum/Quiz/QuestionGradingRule.php +++ b/src/Enum/Quiz/QuestionGradingRule.php @@ -32,7 +32,5 @@ public function rule(): int return $this->rule; } - private function __construct(private int $rule) - { - } + private function __construct(private int $rule) {} } diff --git a/src/Enum/Quiz/QuestionScaleOption.php b/src/Enum/Quiz/QuestionScaleOption.php index d7400c1..4d74915 100644 --- a/src/Enum/Quiz/QuestionScaleOption.php +++ b/src/Enum/Quiz/QuestionScaleOption.php @@ -37,7 +37,5 @@ public function getOption(): int return $this->option; } - private function __construct(private int $option) - { - } + private function __construct(private int $option) {} } diff --git a/src/Enum/Quiz/QuestionStyle.php b/src/Enum/Quiz/QuestionStyle.php index cf2199f..c4cf01f 100644 --- a/src/Enum/Quiz/QuestionStyle.php +++ b/src/Enum/Quiz/QuestionStyle.php @@ -30,7 +30,5 @@ public function style(): int return $this->style; } - private function __construct(private int $style) - { - } + private function __construct(private int $style) {} } diff --git a/src/Enum/RichTextInputType.php b/src/Enum/RichTextInputType.php index 3d54176..363d3d8 100644 --- a/src/Enum/RichTextInputType.php +++ b/src/Enum/RichTextInputType.php @@ -25,7 +25,5 @@ public function type(): string return $this->type; } - private function __construct(private string $type) - { - } + private function __construct(private string $type) {} } diff --git a/src/Exceptions/ExceptionInterface.php b/src/Exceptions/ExceptionInterface.php index 1065742..1f3a66b 100644 --- a/src/Exceptions/ExceptionInterface.php +++ b/src/Exceptions/ExceptionInterface.php @@ -9,6 +9,4 @@ /** * The base interface for all exceptions. */ -interface ExceptionInterface extends Throwable -{ -} +interface ExceptionInterface extends Throwable {} diff --git a/src/Exceptions/InvalidGuidException.php b/src/Exceptions/InvalidGuidException.php index 4301a5f..21d1d6f 100644 --- a/src/Exceptions/InvalidGuidException.php +++ b/src/Exceptions/InvalidGuidException.php @@ -10,7 +10,7 @@ final class InvalidGuidException extends Exception implements ExceptionInterface { - public function __construct(private Guid $guid, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(private Guid $guid, string $message = '', int $code = 0, Throwable|null $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/Exceptions/UserOrgDefinedIdMissingException.php b/src/Exceptions/UserOrgDefinedIdMissingException.php index 571fff5..304b5dc 100644 --- a/src/Exceptions/UserOrgDefinedIdMissingException.php +++ b/src/Exceptions/UserOrgDefinedIdMissingException.php @@ -10,7 +10,7 @@ final class UserOrgDefinedIdMissingException extends Exception implements ExceptionInterface { - public function __construct(private UserData $userData, string $message = '', int $code = 0, ?Throwable $previous = null) + public function __construct(private UserData $userData, string $message = '', int $code = 0, Throwable|null $previous = null) { parent::__construct($message, $code, $previous); } diff --git a/src/GuidGenerator.php b/src/GuidGenerator.php index 6afe6a9..44e08a2 100644 --- a/src/GuidGenerator.php +++ b/src/GuidGenerator.php @@ -13,9 +13,7 @@ final class GuidGenerator { - public function __construct(private ClientInterface $d2lClient) - { - } + public function __construct(private ClientInterface $d2lClient) {} /** * @throws UserOrgDefinedIdMissingException diff --git a/src/Laravel/ServiceProvider.php b/src/Laravel/ServiceProvider.php index 95e11cd..5bda736 100644 --- a/src/Laravel/ServiceProvider.php +++ b/src/Laravel/ServiceProvider.php @@ -72,7 +72,7 @@ public function boot(): void { if ($this->app->runningInConsole()) { $this->publishes([ - __DIR__.'/config/d2l.php' => $this->app->configPath('d2l.php'), + __DIR__ . '/config/d2l.php' => $this->app->configPath('d2l.php'), ], 'd2l-config'); } } diff --git a/src/SymfonyHttpClient.php b/src/SymfonyHttpClient.php index 4a285c0..aec9af4 100644 --- a/src/SymfonyHttpClient.php +++ b/src/SymfonyHttpClient.php @@ -96,8 +96,7 @@ public function __construct( private string $pKey, private string $apiLpVersion, private string $apiLeVersion - ) { - } + ) {} public function getUserById(int $userId): UserData { @@ -387,7 +386,7 @@ public function getBrightspaceDataExportItems(int $page = 1, int $pageSize = 100 ); } - public function findBrightspaceDataExportItemByName(string $name): ?BrightspaceDataSetReportInfo + public function findBrightspaceDataExportItemByName(string $name): BrightspaceDataSetReportInfo|null { $pagedBrightspaceDataSetReportInfo = $this->getBrightspaceDataExportItems(1, 1000); @@ -425,7 +424,7 @@ public function getQuizById(int $orgUnitId, int $quizId): Quiz return $this->getQuizDtoFromQuizArrayResponse($decodedResponse); } - public function quizzesList(int $orgUnitId, ?string $bookmark = null): QuizListPage + public function quizzesList(int $orgUnitId, string|null $bookmark = null): QuizListPage { $method = 'GET'; $path = sprintf( @@ -486,7 +485,7 @@ public function getQuizzesForAnOrganizationUnit(int $orgUnitId): Collection return $result; } - public function quizQuestionsList(int $orgUnitId, int $quizId, ?string $bookmark = null): QuizQuestionListPage + public function quizQuestionsList(int $orgUnitId, int $quizId, string|null $bookmark = null): QuizQuestionListPage { $method = 'GET'; $path = sprintf( @@ -1038,8 +1037,26 @@ public function generateExpiringGuid(string $orgDefinedId): Guid throw ApiException::fromSymfonyHttpException($exception); } + set_error_handler(function ( + int $errorLevel, + string $errorMessage, + string|null $errorFilename = null, + int|null $errorLine = null, + array|null $errorContext = null + ) { + throw new \Exception($errorMessage, $errorLevel); + }); + + try { + $xml = new SimpleXMLElement($body); + } catch (Throwable $e) { + throw new ApiException(sprintf('Invalid response - "%s" given', $body), $e->getCode(), $e); + } finally { + restore_error_handler(); + } + try { - $data = json_decode(json_encode(new SimpleXMLElement($body)), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode(json_encode($xml), true, 512, JSON_THROW_ON_ERROR); } catch (Throwable $e) { throw new ApiException(sprintf('Invalid response - "%s" given', $body), $e->getCode(), $e); } @@ -1075,8 +1092,26 @@ public function validateGuid(Guid $guid, string $orgDefinedId): bool throw ApiException::fromSymfonyHttpException($exception); } + set_error_handler(function ( + int $errorLevel, + string $errorMessage, + string|null $errorFilename = null, + int|null $errorLine = null, + array|null $errorContext = null + ) { + throw new \Exception($errorMessage, $errorLevel); + }); + + try { + $xml = new SimpleXMLElement($body); + } catch (Throwable $e) { + throw new ApiException(sprintf('Invalid response - "%s" given', $body), $e->getCode(), $e); + } finally { + restore_error_handler(); + } + try { - $data = json_decode(json_encode(new SimpleXMLElement($body)), true, 512, JSON_THROW_ON_ERROR); + $data = json_decode(json_encode($xml), true, 512, JSON_THROW_ON_ERROR); } catch (Throwable $e) { throw new ApiException(sprintf('Invalid response - "%s" given', $body), $e->getCode(), $e); } @@ -1110,7 +1145,10 @@ private function getUserDtoFromUserArrayResponse(array $decodedResponse): UserDa ); } - private function buildPreviousDataSets(?array $previousDataSets = null): ?Collection + /** + * @return Collection|null + */ + private function buildPreviousDataSets(array|null $previousDataSets = null): Collection|null { if (null === $previousDataSets) { return null; diff --git a/tests/Unit/CourseUrlGeneratorTest.php b/tests/Unit/CourseUrlGeneratorTest.php index 32bf482..546c1fc 100644 --- a/tests/Unit/CourseUrlGeneratorTest.php +++ b/tests/Unit/CourseUrlGeneratorTest.php @@ -95,7 +95,7 @@ public function testCourseGradesUrlGenerationThrowsUserOrgDefinedIdMissingExcept $courseUrlGenerator->generateCourseGradesUrl($guid, $user, $lmsCourseId); } - private function getUser(?string $orgDefinedId): UserData + private function getUser(string|null $orgDefinedId): UserData { return new UserData( 555, diff --git a/tests/Unit/GuidGeneratorTest.php b/tests/Unit/GuidGeneratorTest.php index 8c35b67..9d6d2c8 100644 --- a/tests/Unit/GuidGeneratorTest.php +++ b/tests/Unit/GuidGeneratorTest.php @@ -74,7 +74,7 @@ public function testItThrowsUserOrgDefinedIdMissingExceptionWhenTheGivenUserDoes $guidGenerator->generateForUser($user); } - private function getUser(?string $orgDefinedId): UserData + private function getUser(string|null $orgDefinedId): UserData { return new UserData( 555, diff --git a/tests/Unit/Laravel/ServiceProviderTest.php b/tests/Unit/Laravel/ServiceProviderTest.php index a3b0d04..7aca6ca 100644 --- a/tests/Unit/Laravel/ServiceProviderTest.php +++ b/tests/Unit/Laravel/ServiceProviderTest.php @@ -107,13 +107,13 @@ public function testItPublishesTheConfig(): void $this->assertSame([ ServiceProvider::class => [ - realpath(__DIR__.'/../../../src/Laravel/config/d2l.php') => $path + realpath(__DIR__ . '/../../../src/Laravel/config/d2l.php') => $path ] ], ServiceProvider::$publishes); $this->assertSame([ 'd2l-config' => [ - realpath(__DIR__.'/../../../src/Laravel/config/d2l.php') => $path + realpath(__DIR__ . '/../../../src/Laravel/config/d2l.php') => $path ] ], ServiceProvider::$publishGroups); }