EntityFactory.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. <?php
  2. namespace Core\App\Factory;
  3. class EntityFactory
  4. {
  5. public $prefix;
  6. const UM = 'BUC';
  7. public function stripSpecialChars($string)
  8. {
  9. $string = str_replace(array("\n", "\r", "&nbsp;"), array('', '', ''), $string);
  10. $string = preg_replace('/[%&\'"]/', '', $string);
  11. $string = html_entity_decode($string, ENT_COMPAT, 'UTF-8');
  12. //$string = preg_replace( '/[^[:print:]]/', '',$string);
  13. return $string;
  14. }
  15. public function setPrefix($prefix)
  16. {
  17. $this->prefix = $prefix;
  18. }
  19. public function getPrefix()
  20. {
  21. return $this->prefix;
  22. }
  23. public function getTaxRate($taxRate)
  24. {
  25. if(empty($taxRate) || !is_numeric($taxRate))
  26. {
  27. return 0;
  28. }
  29. if($taxRate < 1)
  30. {
  31. $tax = $taxRate * 100;
  32. $tax = (int) $tax;
  33. }
  34. else
  35. {
  36. $tax = (int) $taxRate;
  37. }
  38. return $tax;
  39. }
  40. public function getTaxName($taxRate)
  41. {
  42. return $this->getTaxRate($taxRate) . '%';
  43. }
  44. }