Create Check_Result class #11
Labels
Infrastructure
Issues for the overall plugin infrastructure
[Type] Enhancement
A suggestion for improvement of an existing feature
Milestone
Description
The Check_Result class stores all errors, warnings and other messages generated by Check classes. This allows all messages to be recorded to a single repository in a compatible format and consistent API. Once the run of all checks is complete, the Check_Result class will be used to retrieve all results so that they can be presented in a format best suited for the environment (WP-CLI, WP Admin, Continuous Integration Pipeline) in which the checks were run.
The Check_Result class constructor will receive an instance of the Check_Context as an argument. This is so that additional information can be added to each check message such as the file name, path, line, and violation code (a code that is unique to the check/error/warning and can be empty) where the check message occurs. The violation code will be determined by the check itself.
Additionally, this class will contain methods and properties to track the count of errors and warnings to provide an overview of the final results.
Acceptance Criteria
Check_Result.php
should exists atincludes/Checker
$check_context
should be instance ofCheck_Context
class created here Create Check_Context class #10$errors
and$warnings
should be declared as array$error_count
and$warning_count
should be declared as intCheck_Context
class instance as an argumentadd_message
method which will have$error
or$warning
as an argument as a violation code for the check with file name, path, line as an argumentget_errors
method to get list of all errors which will return$errors
get_warnings
method to get list of all errors which will return$warnings
get_error_count
method to get count of errors which will return$error_count
get_warning_count
method to get count of warnings which will return$warning_count
add_message
method adds the message with arguments to the error or warning lists and increments the countsget_errors
method returns all errors expectedget_warnings
method returns all warnings expectedget_error_count
method returns expected error countget_warning_count
method returns expected warning countThe text was updated successfully, but these errors were encountered: