src/Entity/IPFailedLogins.php line 17

Open in your IDE?
  1. <?php
  2. namespace MedBrief\MSR\Entity;
  3. use DateTimeInterface;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use MedBrief\MSR\Repository\IPFailedLoginsRepository;
  6. /**
  7. * @ORM\Entity(repositoryClass=IPFailedLoginsRepository::class)
  8. *
  9. * @ORM\Table(name="IPFailedLogins", indexes={
  10. *
  11. * @ORM\Index(name="idx_ipAddress", columns={"ipAddress"})
  12. * })
  13. */
  14. class IPFailedLogins
  15. {
  16. /**
  17. * @ORM\Id
  18. *
  19. * @ORM\GeneratedValue
  20. *
  21. * @ORM\Column(type="integer")
  22. */
  23. private ?int $id;
  24. /**
  25. * @ORM\Column(type="string", length=45, nullable=true)
  26. */
  27. private ?string $ipAddress = null;
  28. /**
  29. * @ORM\Column(type="text", nullable=true)
  30. */
  31. private ?string $username = null;
  32. /**
  33. * @ORM\Column(type="integer", nullable=true)
  34. */
  35. private ?int $failedCount = null;
  36. /**
  37. * @ORM\Column(type="integer", nullable=true)
  38. */
  39. private ?int $otpFailedCount = null;
  40. /**
  41. * @ORM\Column(type="datetime", nullable=true)
  42. */
  43. private ?DateTimeInterface $firstAttempt;
  44. /**
  45. * @ORM\Column(type="datetime", nullable=true)
  46. */
  47. private ?DateTimeInterface $lastAttempt;
  48. /**
  49. * @ORM\Column(type="datetime", nullable=true)
  50. */
  51. private ?DateTimeInterface $successfulLoginTimeStamp;
  52. /**
  53. * Get the ID of the IPFailedLogins entity.
  54. *
  55. * @return int|null Returns the ID of the IPFailedLogins entity.
  56. */
  57. public function getId(): ?int
  58. {
  59. return $this->id;
  60. }
  61. /**
  62. * Get the IP address of the IPFailedLogins entity.
  63. *
  64. * @return string|null Returns the IP address of the IPFailedLogins entity.
  65. * If the IP address is not set, it returns null.
  66. */
  67. public function getIpAddress(): ?string
  68. {
  69. return $this->ipAddress;
  70. }
  71. /**
  72. * Sets the IP address of the IPFailedLogins entity.
  73. *
  74. * @param string|null $ipAddress The IP address of the IPFailedLogins entity.
  75. * If null, the IP address will be set to null.
  76. *
  77. * @return self Returns the current instance of the IPFailedLogins entity.
  78. * This allows method chaining.
  79. */
  80. public function setIpAddress(?string $ipAddress): self
  81. {
  82. $this->ipAddress = $ipAddress;
  83. return $this;
  84. }
  85. /**
  86. * Get the username of the IPFailedLogins entity.
  87. *
  88. * @return string|null Returns the username of the IPFailedLogins entity.
  89. * If the username is not set, it returns null.
  90. */
  91. public function getUsername(): ?string
  92. {
  93. return $this->username;
  94. }
  95. /**
  96. * Sets the username of the IPFailedLogins entity.
  97. *
  98. * @param string|null $username The username of the IPFailedLogins entity.
  99. * If null, the username will be set to an empty array.
  100. *
  101. * @return self Returns the current instance of the IPFailedLogins entity.
  102. * This allows method chaining.
  103. */
  104. public function setUsername(?string $username): self
  105. {
  106. if ($username !== null) {
  107. $this->username = $username;
  108. } else {
  109. $this->username = json_encode(['']);
  110. }
  111. return $this;
  112. }
  113. /**
  114. * Get the failed count of the IPFailedLogins entity.
  115. *
  116. * @return int|null Returns the failed count of the IPFailedLogins entity.
  117. * If the failed count is not set, it returns 0.
  118. */
  119. public function getFailedCount(): ?int
  120. {
  121. if ($this->failedCount === null) {
  122. return 0;
  123. }
  124. return $this->failedCount;
  125. }
  126. /**
  127. * Sets the failed count of the IPFailedLogins entity.
  128. *
  129. * @param int|null $failedCount The failed count of the IPFailedLogins entity.
  130. * If null, the failed count will be set to null.
  131. *
  132. * @return self Returns the current instance of the IPFailedLogins entity.
  133. * This allows method chaining.
  134. */
  135. public function setFailedCount(?int $failedCount): self
  136. {
  137. $this->failedCount = $failedCount;
  138. return $this;
  139. }
  140. /**
  141. * Gets the OTP failed count of the IPFailedLogins entity.
  142. *
  143. * @return int|null Returns the OTP failed count.
  144. * If the OTP failed count is not set/null, it returns 0.
  145. */
  146. public function getOtpFailedCount(): ?int
  147. {
  148. if ($this->otpFailedCount === null) {
  149. return 0;
  150. }
  151. return $this->otpFailedCount;
  152. }
  153. /**
  154. * Sets the OTP failed count of the IPFailedLogins entity.
  155. *
  156. * @param int|null $otpFailedCount The OTP failed count.
  157. * If null, the OTP failed count will be set to null.
  158. *
  159. * @return self Returns the current instance of the IPFailedLogins entity.
  160. * This allows method chaining.
  161. */
  162. public function setOtpFailedCount(?int $otpFailedCount): self
  163. {
  164. $this->otpFailedCount = $otpFailedCount;
  165. return $this;
  166. }
  167. /**
  168. * Gets the first attempt timestamp of the IPFailedLogins entity.
  169. *
  170. * @return DateTimeInterface|null Returns the first attempt timestamp.
  171. * If the first attempt timestamp is not set, it returns null.
  172. */
  173. public function getFirstAttempt(): ?DateTimeInterface
  174. {
  175. return $this->firstAttempt;
  176. }
  177. /**
  178. * Sets the first attempt timestamp of the IPFailedLogins entity.
  179. *
  180. * @param DateTimeInterface|null $firstAttempt The first attempt timestamp.
  181. * If null, the first attempt timestamp will be set to null.
  182. *
  183. * @return self Returns the current instance of the IPFailedLogins entity.
  184. * This allows method chaining.
  185. */
  186. public function setFirstAttempt(?DateTimeInterface $firstAttempt): self
  187. {
  188. $this->firstAttempt = $firstAttempt;
  189. return $this;
  190. }
  191. /**
  192. * Gets the last attempt timestamp of the IPFailedLogins entity.
  193. *
  194. * @return DateTimeInterface|null Returns the last attempt timestamp.
  195. * If the last attempt timestamp is not set, it returns null.
  196. */
  197. public function getLastAttempt(): ?DateTimeInterface
  198. {
  199. return $this->lastAttempt;
  200. }
  201. /**
  202. * Sets the last attempt timestamp of the IPFailedLogins entity.
  203. *
  204. * @param DateTimeInterface|null $lastAttempt The last attempt timestamp.
  205. * If null, the last attempt timestamp will be set to null.
  206. *
  207. * @return self Returns the current instance of the IPFailedLogins entity.
  208. * This allows method chaining.
  209. */
  210. public function setLastAttempt(?DateTimeInterface $lastAttempt): self
  211. {
  212. $this->lastAttempt = $lastAttempt;
  213. return $this;
  214. }
  215. /**
  216. * Gets the successful login timestamp of the IPFailedLogins entity.
  217. *
  218. * @return DateTimeInterface|null Returns the successful login timestamp.
  219. * If the successful login timestamp is not set, it returns null.
  220. */
  221. public function getSuccessfulLoginTimeStamp(): ?DateTimeInterface
  222. {
  223. return $this->successfulLoginTimeStamp;
  224. }
  225. /**
  226. * Sets the successful login timestamp of the IPFailedLogins entity.
  227. *
  228. * @param DateTimeInterface|null $successfulLoginTimestamp The successful login timestamp.
  229. * If null, the successful login timestamp will be set to null.
  230. * @param ?DateTimeInterface $successfulLoginTimeStamp
  231. *
  232. * @return self Returns the current instance of the IPFailedLogins entity.
  233. * This allows method chaining.
  234. */
  235. public function setSuccessfulLoginTimeStamp(?DateTimeInterface $successfulLoginTimeStamp): self
  236. {
  237. $this->successfulLoginTimeStamp = $successfulLoginTimeStamp;
  238. return $this;
  239. }
  240. }