Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. <?php
  2.  
  3. namespace common\services\Order\SampleOrder;
  4.  
  5. use common\models\Environment;
  6. use common\models\EnvironmentSample;
  7.  
  8. class SampleStatistics
  9. {
  10. /** @var Environment */
  11. private $environment;
  12.  
  13. /** @var int */
  14. public $orderLimit;
  15.  
  16. /** @var int */
  17. public $itemLimit;
  18.  
  19. /** @var int */
  20. public $ordersLeft;
  21.  
  22. /** @var string */
  23. public $level;
  24.  
  25. /**
  26. * @param Environment $environment
  27. */
  28. public function __construct(Environment $environment)
  29. {
  30. $this->environment = $environment;
  31. }
  32.  
  33. /**
  34. * @return $this
  35. */
  36. public function getStatistics(): SampleStatistics
  37. {
  38. if ($this->environment->environmentSample) {
  39. $sample = $this->environment->environmentSample;
  40.  
  41. $this->orderLimit = $sample->order_limit;
  42. $this->itemLimit = $sample->item_limit;
  43. $this->ordersLeft = $sample->orders_left;
  44. $this->level = $sample->sample_type;
  45.  
  46. return $this;
  47. }
  48.  
  49. $levelBase = EnvironmentSample::LEVEL_BASE;
  50. $orderLimit = SampleOrderService::getOrderLimit($levelBase);
  51. $itemLimit = SampleOrderService::getItemLimit($levelBase);
  52.  
  53. $this->orderLimit = $this->ordersLeft = $orderLimit;
  54. $this->itemLimit = $itemLimit;
  55. $this->level = $levelBase;
  56.  
  57. (new SampleTaskService($this->environment))->onRoutineRecalculation();
  58.  
  59. return $this;
  60. }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement