Profile.php 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. <?php
  2. namespace RadiusBundle\Entity;
  3. use Base\AdminBundle\Traits\TenancyIdTrait;
  4. use Base\AdminBundle\Traits\TenancyIdTraitInterface;
  5. use Doctrine\ORM\Mapping as ORM;
  6. use ExtraDataBundle\Entity\Traits\ExtraDataTrait;
  7. use Symfony\Component\Validator\Constraints as Assert;
  8. use JMS\Serializer\Annotation as JMS;
  9. /**
  10. * @ORM\Table
  11. * @ORM\Entity
  12. */
  13. class Profile implements TenancyIdTraitInterface
  14. {
  15. use ExtraDataTrait;
  16. use TenancyIdTrait;
  17. /**
  18. * @var int
  19. *
  20. * @ORM\Column(name="id", type="integer")
  21. * @ORM\Id
  22. * @ORM\GeneratedValue(strategy="AUTO")
  23. */
  24. private $id;
  25. /**
  26. * @var string
  27. *
  28. * @ORM\Column(type="string", length=255)
  29. * @Assert\NotNull
  30. */
  31. private $name;
  32. /**
  33. * @var int
  34. *
  35. * @ORM\Column(type="bigint", nullable=true)
  36. */
  37. private $upload;
  38. /**
  39. * @var int
  40. *
  41. * @ORM\Column(type="bigint", nullable=true)
  42. */
  43. private $download;
  44. /**
  45. * @return string
  46. */
  47. public function __toString()
  48. {
  49. return (string)$this->name;
  50. }
  51. /**
  52. * @return int
  53. */
  54. public function getId()
  55. {
  56. return $this->id;
  57. }
  58. /**
  59. * @param int $id
  60. *
  61. * @return Profile
  62. */
  63. public function setId($id)
  64. {
  65. $this->id = $id;
  66. return $this;
  67. }
  68. /**
  69. * @param string $name
  70. *
  71. * @return Profile
  72. */
  73. public function setName($name)
  74. {
  75. $this->name = $name;
  76. return $this;
  77. }
  78. /**
  79. * @return string
  80. */
  81. public function getName()
  82. {
  83. return $this->name;
  84. }
  85. /**
  86. * @param integer $upload
  87. *
  88. * @return Profile
  89. */
  90. public function setUpload($upload)
  91. {
  92. $this->upload = $upload;
  93. return $this;
  94. }
  95. /**
  96. * @return int
  97. */
  98. public function getUpload()
  99. {
  100. return $this->upload;
  101. }
  102. /**
  103. * @param integer $download
  104. *
  105. * @return Profile
  106. */
  107. public function setDownload($download)
  108. {
  109. $this->download = $download;
  110. return $this;
  111. }
  112. /**
  113. * @return int
  114. */
  115. public function getDownload()
  116. {
  117. return $this->download;
  118. }
  119. /**
  120. * @return string
  121. */
  122. public function getDownloadAsK()
  123. {
  124. return round($this->getDownload() / 1000, 2) . "k";
  125. }
  126. /**
  127. * @return string
  128. */
  129. public function getUploadAsK()
  130. {
  131. return round($this->getUpload() / 1000, 2) . "k";
  132. }
  133. /**
  134. * @return string
  135. */
  136. public function getRadiusName()
  137. {
  138. return preg_replace("|[^A-Za-z0-9]|", "-", $this->name);
  139. }
  140. }