aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan-Hendrik Willms <tleilax+studip@gmail.com>2023-03-11 11:54:01 +0000
committerDavid Siegfried <david.siegfried@uni-vechta.de>2023-03-11 11:54:01 +0000
commit80fcb757898f46618efb6ea8f85dde505ed35bd6 (patch)
tree6bd8965931109bef7df50aa8567d0ba1d395e6f1
parent7f3db49259880e500fb711f020543f8237f672ba (diff)
prevent php8 warnings, fixes #2279
Closes #2279 Merge request studip/studip!1504
-rw-r--r--lib/classes/JsonApi/Schemas/Courseware/Instance.php2
-rw-r--r--lib/models/Courseware/Instance.php10
2 files changed, 9 insertions, 3 deletions
diff --git a/lib/classes/JsonApi/Schemas/Courseware/Instance.php b/lib/classes/JsonApi/Schemas/Courseware/Instance.php
index ff10966..c522475 100644
--- a/lib/classes/JsonApi/Schemas/Courseware/Instance.php
+++ b/lib/classes/JsonApi/Schemas/Courseware/Instance.php
@@ -26,6 +26,8 @@ class Instance extends SchemaProvider
/**
* {@inheritdoc}
+ *
+ * @param \Courseware\Instance $resource
*/
public function getAttributes($resource, ContextInterface $context): iterable
{
diff --git a/lib/models/Courseware/Instance.php b/lib/models/Courseware/Instance.php
index 5cff953..97990f6 100644
--- a/lib/models/Courseware/Instance.php
+++ b/lib/models/Courseware/Instance.php
@@ -284,7 +284,11 @@ class Instance
*/
public function isValidCertificateSettings($certificateSettings): bool
{
- return (int) $certificateSettings['threshold'] >= 0 && (int) $certificateSettings['threshold'] <= 100;
+ return !isset($certificateSettings['threshold'])
+ || (
+ $certificateSettings['threshold'] >= 0
+ && $certificateSettings['threshold'] <= 100
+ );
}
private function validateCertificateSettings($certificateSettings): void
@@ -335,7 +339,7 @@ class Instance
*/
public function isValidReminderSettings($reminderSettings): bool
{
- $valid = in_array($reminderSettings['interval'], [0, 7, 14, 30, 90, 180, 365]);
+ $valid = in_array($reminderSettings['interval'] ?? 0, [0, 7, 14, 30, 90, 180, 365]);
return $valid;
}
@@ -388,7 +392,7 @@ class Instance
*/
public function isValidResetProgressSettings($resetProgressSettings): bool
{
- $valid = in_array($resetProgressSettings['interval'], [0, 14, 30, 90, 180, 365]);
+ $valid = in_array($resetProgressSettings['interval'] ?? 0, [0, 14, 30, 90, 180, 365]);
return $valid;
}