From ae3104612714a6e7f886e20cbc4f66946bad6db0 Mon Sep 17 00:00:00 2001 From: Stefan Hanauska Date: Thu, 8 Aug 2024 08:09:52 +0200 Subject: [PATCH] Coding style --- classes/condition.php | 13 ++++----- classes/frontend.php | 2 +- classes/privacy/provider.php | 3 +-- .../availability_user_condition_testcase.php | 27 +++++++++---------- 4 files changed, 22 insertions(+), 23 deletions(-) diff --git a/classes/condition.php b/classes/condition.php index bc6b0c8..d59199a 100644 --- a/classes/condition.php +++ b/classes/condition.php @@ -29,10 +29,11 @@ * Condition to restrict access by user */ class condition extends \core_availability\condition { - /** - * @var int ID of the required user - */ - protected $userid; + /** @var int ID of the required user */ + protected int $userid; + + /** @var array $userids The user ids that the condition checks for */ + protected array $userids; /** * Constructor @@ -120,7 +121,7 @@ public function get_description($full, $not, \core_availability\info $info) { array_push($usernames, fullname($user)); } } - return get_string('requires_'.($not ? 'not_' : '').'users', 'availability_user', implode(', ', $usernames)); + return get_string('requires_' . ($not ? 'not_' : '') . 'users', 'availability_user', implode(', ', $usernames)); } else { $user = \core_user::get_user($this->userids[0]); if (!$user) { @@ -128,7 +129,7 @@ public function get_description($full, $not, \core_availability\info $info) { } else { $fullname = fullname($user); } - return get_string('requires_'.($not ? 'not_' : '').'user', 'availability_user', $fullname); + return get_string('requires_' . ($not ? 'not_' : '') . 'user', 'availability_user', $fullname); } } else { return get_string('requires_certain_user', 'availability_user'); diff --git a/classes/frontend.php b/classes/frontend.php index 6b57367..b9d0107 100644 --- a/classes/frontend.php +++ b/classes/frontend.php @@ -51,7 +51,7 @@ protected function get_javascript_init_params($course, \cm_info $cm = null, \sec $participantlist = []; foreach ($participants as $p) { array_push($participantlist, ['firstname' => $p->firstname, 'lastname' => $p->lastname, - 'fullname' => fullname($p), 'id' => $p->id]); + 'fullname' => fullname($p), 'id' => $p->id, ]); } return [$participantlist]; } diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php index b9a9478..10765b2 100644 --- a/classes/privacy/provider.php +++ b/classes/privacy/provider.php @@ -31,14 +31,13 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ class provider implements \core_privacy\local\metadata\null_provider { - /** * Get the language string identifier with the component's language * file to explain why this plugin stores no data. * * @return string */ - public static function get_reason() : string { + public static function get_reason(): string { return 'privacy:metadata'; } } diff --git a/tests/availability_user_condition_testcase.php b/tests/availability_user_condition_testcase.php index 2d3a435..cbb08d9 100644 --- a/tests/availability_user_condition_testcase.php +++ b/tests/availability_user_condition_testcase.php @@ -28,7 +28,6 @@ * Testcase for availability_user */ class availability_user_condition_testcase extends advanced_testcase { - /** * Load necessary libs */ @@ -47,34 +46,34 @@ public function setUp(): void { $this->capabilitychecker = new \core_availability\capability_checker($this->info->get_context()); $this->resetAfterTest(); $this->user1 = $this->getDataGenerator()->create_user( - array( + [ 'email' => 'user1@example.com', - 'username' => 'user1') + 'username' => 'user1', ] ); $this->user2 = $this->getDataGenerator()->create_user( - array( + [ 'email' => 'user2@example.com', - 'username' => 'user2') + 'username' => 'user2', ] ); $this->user3 = $this->getDataGenerator()->create_user( - array( + [ 'email' => 'user3@example.com', - 'username' => 'user3') + 'username' => 'user3', ] ); $this->user4 = $this->getDataGenerator()->create_user( - array( + [ 'email' => 'user4@example.com', - 'username' => 'user4') + 'username' => 'user4', ] ); - $oldstructure = new stdClass; + $oldstructure = new stdClass(); $oldstructure->userid = $this->user1->id; $this->cond = new condition($oldstructure); - $newstructure = new stdClass; + $newstructure = new stdClass(); $newstructure->userids = [$this->user1->id]; $this->newcond = new condition($newstructure); - $multiplestructure = new stdClass; + $multiplestructure = new stdClass(); $multiplestructure->userids = [$this->user1->id, $this->user2->id, $this->user3->id]; $this->multiplecond = new condition($multiplestructure); } @@ -243,7 +242,7 @@ public function test_users_multiple_filter() { $this->user1->id => $this->user1, $this->user2->id => $this->user2, $this->user3->id => $this->user3, - $this->user4->id => $this->user4 + $this->user4->id => $this->user4, ]; $filteredlist = $this->multiplecond->filter_user_list($users, false, $this->info, $this->capabilitychecker); $filtereduserids = array_keys($filteredlist); @@ -263,7 +262,7 @@ public function test_users_multiple_filter_not() { $this->user1->id => $this->user1, $this->user2->id => $this->user2, $this->user3->id => $this->user3, - $this->user4->id => $this->user4 + $this->user4->id => $this->user4, ]; $filteredlist = $this->multiplecond->filter_user_list($users, true, $this->info, $this->capabilitychecker); $filtereduserids = array_keys($filteredlist);