Problem.php 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. namespace Grav\Plugin\Problems\Base;
  3. class Problem implements \JsonSerializable
  4. {
  5. const LEVEL_CRITICAL = 'critical';
  6. const LEVEL_WARNING = 'warning';
  7. const LEVEL_NOTICE = 'notice';
  8. protected $id;
  9. protected $order;
  10. protected $level;
  11. protected $status;
  12. protected $msg;
  13. protected $details;
  14. protected $help;
  15. protected $class;
  16. public function __contstruct($data = null)
  17. {
  18. if (!is_null($data)) {
  19. $this->load($data);
  20. }
  21. }
  22. public function load($data) {
  23. $this->set_object_vars($data);
  24. }
  25. public function process() {
  26. return $this;
  27. }
  28. public function getId() {
  29. return $this->id;
  30. }
  31. public function getOrder() {
  32. return $this->order;
  33. }
  34. public function getLevel() {
  35. return $this->level;
  36. }
  37. public function getStatus() {
  38. return $this->status;
  39. }
  40. public function getMsg() {
  41. return $this->msg;
  42. }
  43. public function getDetails()
  44. {
  45. return $this->details;
  46. }
  47. public function getHelp()
  48. {
  49. return $this->help;
  50. }
  51. public function getClass()
  52. {
  53. return $this->class;
  54. }
  55. public function toArray()
  56. {
  57. return get_object_vars($this);
  58. }
  59. public function jsonSerialize()
  60. {
  61. $this->toArray();
  62. }
  63. protected function set_object_vars($object, array $vars) {
  64. $has = get_object_vars($object);
  65. foreach ($has as $name => $oldValue) {
  66. $object->$name = isset($vars[$name]) ? $vars[$name] : NULL;
  67. }
  68. }
  69. }