Problem.php 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 load($data)
  17. {
  18. $this->set_object_vars($data);
  19. }
  20. public function process()
  21. {
  22. return $this;
  23. }
  24. public function getId()
  25. {
  26. return $this->id;
  27. }
  28. public function getOrder()
  29. {
  30. return $this->order;
  31. }
  32. public function getLevel()
  33. {
  34. return $this->level;
  35. }
  36. public function getStatus()
  37. {
  38. return $this->status;
  39. }
  40. public function getMsg()
  41. {
  42. return $this->msg;
  43. }
  44. public function getDetails()
  45. {
  46. return $this->details;
  47. }
  48. public function getHelp()
  49. {
  50. return $this->help;
  51. }
  52. public function getClass()
  53. {
  54. return $this->class;
  55. }
  56. public function toArray()
  57. {
  58. return get_object_vars($this);
  59. }
  60. public function jsonSerialize()
  61. {
  62. $this->toArray();
  63. }
  64. protected function set_object_vars(array $vars)
  65. {
  66. $has = get_object_vars($this);
  67. foreach ($has as $name => $oldValue) {
  68. $this->{$name} = isset($vars[$name]) ? $vars[$name] : NULL;
  69. }
  70. }
  71. }