diff options
author | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
---|---|---|
committer | Christoph Wurst <christoph@winzerhof-wurst.at> | 2020-04-10 14:19:56 +0200 |
commit | caff1023ea72bb2ea94130e18a2a6e2ccf819e5f (patch) | |
tree | 186d494c2aea5dea7255d3584ef5d595fc6e6194 /tests/lib/Util | |
parent | edf8ce32cffdb920e8171207b342abbd7f1fbe73 (diff) | |
download | nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.tar.gz nextcloud-server-caff1023ea72bb2ea94130e18a2a6e2ccf819e5f.zip |
Format control structures, classes, methods and function
To continue this formatting madness, here's a tiny patch that adds
unified formatting for control structures like if and loops as well as
classes, their methods and anonymous functions. This basically forces
the constructs to start on the same line. This is not exactly what PSR2
wants, but I think we can have a few exceptions with "our" style. The
starting of braces on the same line is pracrically standard for our
code.
This also removes and empty lines from method/function bodies at the
beginning and end.
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'tests/lib/Util')
-rw-r--r-- | tests/lib/Util/Group/Dummy.php | 57 | ||||
-rw-r--r-- | tests/lib/Util/User/Dummy.php | 2 |
2 files changed, 29 insertions, 30 deletions
diff --git a/tests/lib/Util/Group/Dummy.php b/tests/lib/Util/Group/Dummy.php index f75aef5737e..293c8f48945 100644 --- a/tests/lib/Util/Group/Dummy.php +++ b/tests/lib/Util/Group/Dummy.php @@ -45,10 +45,10 @@ class Dummy extends Backend { * be returned. */ public function createGroup($gid) { - if(!isset($this->groups[$gid])) { + if (!isset($this->groups[$gid])) { $this->groups[$gid]=[]; return true; - }else{ + } else { return false; } } @@ -61,10 +61,10 @@ class Dummy extends Backend { * Deletes a group and removes it from the group_user-table */ public function deleteGroup($gid) { - if(isset($this->groups[$gid])) { + if (isset($this->groups[$gid])) { unset($this->groups[$gid]); return true; - }else{ + } else { return false; } } @@ -78,9 +78,9 @@ class Dummy extends Backend { * Checks whether the user is member of a group or not. */ public function inGroup($uid, $gid) { - if(isset($this->groups[$gid])) { + if (isset($this->groups[$gid])) { return (array_search($uid, $this->groups[$gid])!==false); - }else{ + } else { return false; } } @@ -94,14 +94,14 @@ class Dummy extends Backend { * Adds a user to a group. */ public function addToGroup($uid, $gid) { - if(isset($this->groups[$gid])) { - if(array_search($uid, $this->groups[$gid])===false) { + if (isset($this->groups[$gid])) { + if (array_search($uid, $this->groups[$gid])===false) { $this->groups[$gid][]=$uid; return true; - }else{ + } else { return false; } - }else{ + } else { return false; } } @@ -115,14 +115,14 @@ class Dummy extends Backend { * removes the user from a group. */ public function removeFromGroup($uid, $gid) { - if(isset($this->groups[$gid])) { - if(($index=array_search($uid, $this->groups[$gid]))!==false) { + if (isset($this->groups[$gid])) { + if (($index=array_search($uid, $this->groups[$gid]))!==false) { unset($this->groups[$gid][$index]); return true; - }else{ + } else { return false; } - }else{ + } else { return false; } } @@ -138,8 +138,8 @@ class Dummy extends Backend { public function getUserGroups($uid) { $groups=[]; $allGroups=array_keys($this->groups); - foreach($allGroups as $group) { - if($this->inGroup($uid, $group)) { + foreach ($allGroups as $group) { + if ($this->inGroup($uid, $group)) { $groups[]=$group; } } @@ -154,12 +154,12 @@ class Dummy extends Backend { * @return array an array of group names */ public function getGroups($search = '', $limit = -1, $offset = 0) { - if(empty($search)) { + if (empty($search)) { return array_keys($this->groups); } $result = []; - foreach(array_keys($this->groups) as $group) { - if(stripos($group, $search) !== false) { + foreach (array_keys($this->groups) as $group) { + if (stripos($group, $search) !== false) { $result[] = $group; } } @@ -175,19 +175,19 @@ class Dummy extends Backend { * @return array an array of user IDs */ public function usersInGroup($gid, $search = '', $limit = -1, $offset = 0) { - if(isset($this->groups[$gid])) { - if(empty($search)) { + if (isset($this->groups[$gid])) { + if (empty($search)) { $length = $limit < 0 ? null : $limit; return array_slice($this->groups[$gid], $offset, $length); } $result = []; - foreach($this->groups[$gid] as $user) { - if(stripos($user, $search) !== false) { + foreach ($this->groups[$gid] as $user) { + if (stripos($user, $search) !== false) { $result[] = $user; } } return $result; - }else{ + } else { return []; } } @@ -201,18 +201,17 @@ class Dummy extends Backend { * @return int */ public function countUsersInGroup($gid, $search = '', $limit = -1, $offset = 0) { - if(isset($this->groups[$gid])) { - if(empty($search)) { + if (isset($this->groups[$gid])) { + if (empty($search)) { return count($this->groups[$gid]); } $count = 0; - foreach($this->groups[$gid] as $user) { - if(stripos($user, $search) !== false) { + foreach ($this->groups[$gid] as $user) { + if (stripos($user, $search) !== false) { $count++; } } return $count; } } - } diff --git a/tests/lib/Util/User/Dummy.php b/tests/lib/Util/User/Dummy.php index 3e6372ca033..478b7599701 100644 --- a/tests/lib/Util/User/Dummy.php +++ b/tests/lib/Util/User/Dummy.php @@ -109,7 +109,7 @@ class Dummy extends Backend implements \OCP\IUserBackend { } public function loginName2UserName($loginName) { - if(isset($this->users[strtolower($loginName)])) { + if (isset($this->users[strtolower($loginName)])) { return strtolower($loginName); } return false; |