\GB_User
GeniBase User class.
Synopsis
class GB_User
{
- // members
- public $data;
- public integer $ID = 0;
- public array $caps = ;
- public $cap_key;
- public array $roles = ;
- public array $allcaps = ;
- public $filter = NULL;
- // methods
- public GB_User __construct()
- public void init()
- public static void generate_hash()
- public static string hash()
- public static get_data_by()
- public void __isset()
- public void __get()
- public void __set()
- public bool exists()
- public void get()
- public void has_prop()
- public void to_array()
- public void _init_caps()
- public void get_role_caps()
- public void add_role()
- public void remove_role()
- public void set_role()
- public void add_cap()
- public void remove_cap()
- public void remove_all_caps()
- public static array map_cap()
- public bool has_cap()
- public static int|bool add_meta()
- public static bool delete_meta()
- public static mixed get_meta()
- public static int|bool update_meta()
- public mixed sanitize_field()
Violations
PHPMessDetector
Line | Rule | Message |
---|---|---|
40 | ShortVariable | Avoid variables with short names like $ID. Configured minimum length is 3. |
103 | ShortVariable | Avoid variables with short names like $id. Configured minimum length is 3. |
220 - 267 | CyclomaticComplexity | The method get_data_by() has a Cyclomatic Complexity of 11. The configured cyclomatic complexity threshold is 10. |
596 - 682 | CyclomaticComplexity | The method map_cap() has a Cyclomatic Complexity of 33. The configured cyclomatic complexity threshold is 10. |
821 - 927 | CyclomaticComplexity | The method sanitize_field() has a Cyclomatic Complexity of 15. The configured cyclomatic complexity threshold is 10. |
821 - 927 | NPathComplexity | The method sanitize_field() has an NPath complexity of 864. The configured NPath complexity threshold is 200. |
821 - 927 | ExcessiveMethodLength | The method sanitize_field() has 107 lines of code. Current threshold is set to 100. Avoid really long methods. |
Checkstyle
Line | Column | Severity | Message |
---|---|---|---|
31 | 9 | error | The var keyword must not be used to declare a property |
31 | 9 | error | Visibility must be declared on property "$data" |
40 | 9 | error | The var keyword must not be used to declare a property |
40 | 9 | error | Visibility must be declared on property "$ID" |
49 | 9 | error | The var keyword must not be used to declare a property |
49 | 9 | error | Visibility must be declared on property "$caps" |
58 | 9 | error | The var keyword must not be used to declare a property |
58 | 9 | error | Visibility must be declared on property "$cap_key" |
67 | 9 | error | The var keyword must not be used to declare a property |
67 | 9 | error | Visibility must be declared on property "$roles" |
76 | 9 | error | The var keyword must not be used to declare a property |
76 | 9 | error | Visibility must be declared on property "$allcaps" |
87 | 9 | error | The var keyword must not be used to declare a property |
87 | 9 | error | Visibility must be declared on property "$filter" |
103 | 5 | error | Visibility must be declared on method "__construct" |
118 | 9 | error | Inline control structures are not allowed |
120 | 9 | error | Expected 1 space after ELSE keyword; newline found |
120 | 9 | error | Inline control structures are not allowed |
123 | 9 | error | Inline control structures are not allowed |
133 | 5 | error | Visibility must be declared on method "init" |
141 | 12 | error | Method name "GB_User::generate_hash" is not in camel caps format |
141 | 12 | error | Visibility must be declared on method "generate_hash" |
160 | 11 | error | Whitespace found at end of line |
179 | 12 | error | Visibility must be declared on method "hash" |
200 | 127 | warning | Line exceeds 120 characters; contains 127 characters |
201 | 123 | warning | Line exceeds 120 characters; contains 123 characters |
220 | 12 | error | Method name "GB_User::get_data_by" is not in camel caps format |
220 | 12 | error | Visibility must be declared on method "get_data_by" |
225 | 13 | error | Inline control structures are not allowed |
232 | 9 | error | Inline control structures are not allowed |
254 | 13 | error | Inline control structures are not allowed |
258 | 9 | error | Inline control structures are not allowed |
274 | 5 | error | Visibility must be declared on method "__isset" |
276 | 9 | error | Inline control structures are not allowed |
287 | 5 | error | Visibility must be declared on method "__get" |
305 | 5 | error | Visibility must be declared on method "__set" |
318 | 5 | error | Visibility must be declared on method "exists" |
333 | 5 | error | Visibility must be declared on method "get" |
348 | 5 | error | Method name "GB_User::has_prop" is not in camel caps format |
348 | 5 | error | Visibility must be declared on method "has_prop" |
360 | 5 | error | Method name "GB_User::to_array" is not in camel caps format |
360 | 5 | error | Visibility must be declared on method "to_array" |
379 | 5 | warning | Method name "_init_caps" should not be prefixed with an underscore to indicate visibility |
379 | 5 | error | Method name "GB_User::_init_caps" is not in camel caps format |
379 | 5 | error | Visibility must be declared on method "_init_caps" |
381 | 9 | error | Inline control structures are not allowed |
383 | 9 | error | Expected 1 space after ELSE keyword; newline found |
383 | 9 | error | Inline control structures are not allowed |
388 | 9 | error | Inline control structures are not allowed |
406 | 5 | error | Method name "GB_User::get_role_caps" is not in camel caps format |
406 | 5 | error | Visibility must be declared on method "get_role_caps" |
411 | 9 | error | Inline control structures are not allowed |
437 | 5 | error | Method name "GB_User::add_role" is not in camel caps format |
437 | 5 | error | Visibility must be declared on method "add_role" |
447 | 11 | error | Whitespace found at end of line |
465 | 5 | error | Method name "GB_User::remove_role" is not in camel caps format |
465 | 5 | error | Visibility must be declared on method "remove_role" |
467 | 9 | error | Inline control structures are not allowed |
477 | 11 | error | Whitespace found at end of line |
499 | 5 | error | Method name "GB_User::set_role" is not in camel caps format |
499 | 5 | error | Visibility must be declared on method "set_role" |
501 | 9 | error | Inline control structures are not allowed |
547 | 5 | error | Method name "GB_User::add_cap" is not in camel caps format |
547 | 5 | error | Visibility must be declared on method "add_cap" |
562 | 5 | error | Method name "GB_User::remove_cap" is not in camel caps format |
562 | 5 | error | Visibility must be declared on method "remove_cap" |
564 | 9 | error | Inline control structures are not allowed |
576 | 5 | error | Method name "GB_User::remove_all_caps" is not in camel caps format |
576 | 5 | error | Visibility must be declared on method "remove_all_caps" |
596 | 12 | error | Method name "GB_User::map_cap" is not in camel caps format |
596 | 12 | error | Visibility must be declared on method "map_cap" |
611 | 17 | error | Inline control structures are not allowed |
671 | 11 | error | Whitespace found at end of line |
698 | 5 | error | Method name "GB_User::has_cap" is not in camel caps format |
698 | 5 | error | Visibility must be declared on method "has_cap" |
711 | 13 | error | Inline control structures are not allowed |
735 | 12 | error | Method name "GB_User::add_meta" is not in camel caps format |
735 | 12 | error | Visibility must be declared on method "add_meta" |
757 | 12 | error | Method name "GB_User::delete_meta" is not in camel caps format |
757 | 12 | error | Visibility must be declared on method "delete_meta" |
776 | 12 | error | Method name "GB_User::get_meta" is not in camel caps format |
776 | 12 | error | Visibility must be declared on method "get_meta" |
801 | 12 | error | Method name "GB_User::update_meta" is not in camel caps format |
801 | 12 | error | Visibility must be declared on method "update_meta" |
821 | 12 | error | Method name "GB_User::sanitize_field" is not in camel caps format |
826 | 9 | error | Inline control structures are not allowed |
829 | 9 | error | Inline control structures are not allowed |
832 | 9 | error | Inline control structures are not allowed |
853 | 19 | error | Whitespace found at end of line |
862 | 13 | error | Inline control structures are not allowed |
864 | 13 | error | Expected 1 space after ELSE keyword; newline found |
864 | 13 | error | Inline control structures are not allowed |
866 | 11 | warning | Usage of ELSE IF is discouraged; use ELSEIF instead |
866 | 11 | error | Expected 1 space after ELSE keyword; newline found |
866 | 15 | error | Whitespace found at end of line |
867 | 13 | error | Line indented incorrectly; expected 8 spaces, found 12 |
868 | 17 | error | Line indented incorrectly; expected 12 spaces, found 16 |
873 | 17 | error | Line indented incorrectly; expected 12 spaces, found 16 |
882 | 23 | error | Whitespace found at end of line |
887 | 17 | error | Line indented incorrectly; expected 12 spaces, found 16 |
888 | 13 | error | Line indented incorrectly; expected 8 spaces, found 12 |
890 | 17 | error | Line indented incorrectly; expected 12 spaces, found 16 |
896 | 17 | error | Line indented incorrectly; expected 12 spaces, found 16 |
905 | 23 | error | Whitespace found at end of line |
914 | 17 | error | Line indented incorrectly; expected 12 spaces, found 16 |
915 | 13 | error | Line indented incorrectly; expected 8 spaces, found 12 |
917 | 9 | error | Inline control structures are not allowed |
920 | 9 | error | Inline control structures are not allowed |
922 | 9 | warning | Usage of ELSE IF is discouraged; use ELSEIF instead |
922 | 9 | error | Expected 1 space after ELSE keyword; newline found |
922 | 13 | error | Whitespace found at end of line |
923 | 13 | error | Inline control structures are not allowed |
Members
public
- $ID
—
int
The user's ID. - $allcaps
—
array
All capabilities the user has, including individual and role based. - $cap_key
—
string
User metadata option name. - $caps
—
array
The individual capabilities the user has been given. - $data
—
array
User data container. - $filter
—
string
The filter context applied to user data fields. - $roles
—
array
The roles the user is part of.
Methods
public
- __construct() — Constructor
- __get() — Magic method for accessing custom fields
- __isset() — Magic method for checking the existence of a certain custom field
- __set() — Magic method for setting custom fields
- _init_caps() — Set up capability object properties.
- add_cap() — Add capability and grant or deny access to capability.
- add_meta() — Add meta data field to a user.
- add_role() — Add role to user.
- delete_meta() — Remove metadata matching criteria from a user.
- exists() — Determine whether the user exists in the database.
- generate_hash()
- get() — Retrieve the value of a property or meta key.
- get_data_by() — Return only the main user fields
- get_meta() — Retrieve user meta field for a user.
- get_role_caps() — Retrieve all of the role capabilities and merge with individual capabilities.
- has_cap() — Whether user has capability or role name.
- has_prop() — Determine whether a property or meta key is set
- hash() — Get current or set new user hash.
- init() — Sets up object properties, including capabilities.
- map_cap() — Map meta capabilities to primitive capabilities.
- remove_all_caps() — Remove all of the capabilities of the user.
- remove_cap() — Remove capability from user.
- remove_role() — Remove role from user.
- sanitize_field() — Sanitize user field based on context.
- set_role() — Set the role of the user.
- to_array()
- update_meta() — Update user meta field based on user ID.
History
-
2017-05-18T21:45:34+00:00 (commit #62babba)
Author: Limych (andrey@khrolenok.ru) / Commiter: Limych (andrey@khrolenok.ru)
Pre 3.0.0
-
2017-05-16T19:52:59+00:00 (commit #fd0a296)
Author: Limych (andrey@khrolenok.ru) / Commiter: Limych (andrey@khrolenok.ru)
PSR-2 applied
-
2016-01-25T17:45:50+00:00 (commit #97e2af2)
Author: Limych (andrey@khrolenok.ru) / Commiter: Limych (andrey@khrolenok.ru)
Pre v.3.0