AbstractSerialize.php 923 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace ThurData\Servers\KerioEmail\App\Services\ConfigurableOptions\Abstracts;
  3. /**
  4. * Description of TypeConstans
  5. *
  6. * @author Mateusz Pawłowski <mateusz.pa@thurdata.com>
  7. */
  8. abstract class AbstractSerialize
  9. {
  10. protected function prepareName($key, $name = null)
  11. {
  12. if (is_null($name))
  13. {
  14. return $key . "|" . $key;
  15. }
  16. return $key . "|" . $name;
  17. }
  18. public function toArray()
  19. {
  20. $out = [];
  21. foreach (get_class_vars(get_called_class()) as $property => $value)
  22. {
  23. if (!isset($this->{$property}))
  24. {
  25. continue;
  26. }
  27. if (is_object($this->$property) || is_array($this->$property))
  28. {
  29. continue;
  30. }
  31. else
  32. {
  33. $out[$property] = $this->{$property};
  34. }
  35. }
  36. return $out;
  37. }
  38. }