src/MobileAppApi/Entity/CallLogEntry.php line 23

Open in your IDE?
  1. <?php
  2. namespace MobileAppApi\Entity;
  3. use App\Entity\User;
  4. use App\Utility\DateTimeUtility;
  5. use DateTime;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8. * @ORM\Entity
  9. *
  10. * @ORM\Table(
  11. * name="mobile_app_api_call_log_entries",
  12. * indexes={
  13. *
  14. * @ORM\Index(name="created_at", columns={"created_at"}),
  15. * @ORM\Index(name="users_id", columns={"users_id"}),
  16. * @ORM\Index(name="mobile_app_api_keys_id", columns={"mobile_app_api_keys_id"})
  17. * }
  18. * )
  19. */
  20. class CallLogEntry
  21. {
  22. public function __construct()
  23. {
  24. $this->createdAt = DateTimeUtility::createDateTimeUtc();
  25. }
  26. /**
  27. * @var string
  28. *
  29. * @ORM\GeneratedValue(strategy="CUSTOM")
  30. *
  31. * @ORM\CustomIdGenerator(class="App\Utility\DatabaseIdGenerator")
  32. *
  33. * @ORM\Column(name="id", type="guid")
  34. *
  35. * @ORM\Id
  36. */
  37. private $id;
  38. public function getId(): string
  39. {
  40. return $this->id;
  41. }
  42. /**
  43. * @var User|null
  44. *
  45. * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="mobileAppApiKeys")
  46. *
  47. * @ORM\JoinColumn(name="users_id", onDelete="CASCADE", nullable=true)
  48. */
  49. protected $user;
  50. public function setUser(?User $user): void
  51. {
  52. $this->user = $user;
  53. }
  54. public function getUser(): ?User
  55. {
  56. return $this->user;
  57. }
  58. /**
  59. * @var ApiKey|null
  60. *
  61. * @ORM\ManyToOne(targetEntity="MobileAppApi\Entity\ApiKey")
  62. *
  63. * @ORM\JoinColumn(name="mobile_app_api_keys_id", onDelete="SET NULL", nullable=true)
  64. */
  65. protected $apiKey;
  66. public function setApiKey(?ApiKey $apiKey): void
  67. {
  68. $this->apiKey = $apiKey;
  69. }
  70. public function getApiKey(): ?ApiKey
  71. {
  72. return $this->apiKey;
  73. }
  74. /**
  75. * @var string|null
  76. *
  77. * @ORM\Column(name="api_key_from_request", type="text", length=256, nullable=true)
  78. */
  79. protected $apiKeyFromRequest;
  80. public function setApiKeyFromRequest(?string $apiKeyFromRequest): void
  81. {
  82. $this->apiKeyFromRequest = $apiKeyFromRequest;
  83. }
  84. public function getApiKeyFromRequest(): ?string
  85. {
  86. return $this->apiKeyFromRequest;
  87. }
  88. /**
  89. * @var DateTime
  90. *
  91. * @ORM\Column(name="created_at", type="datetime", nullable=false)
  92. */
  93. protected $createdAt;
  94. public function setCreatedAt(DateTime $createdAt): void
  95. {
  96. $this->createdAt = $createdAt;
  97. }
  98. public function getCreatedAt(): DateTime
  99. {
  100. return $this->createdAt;
  101. }
  102. /**
  103. * @var bool
  104. *
  105. * @ORM\Column(name="resulted_in_exception", type="boolean", nullable=false)
  106. */
  107. protected $resultedInException;
  108. public function setResultedInException(bool $resultedInException): void
  109. {
  110. $this->resultedInException = $resultedInException;
  111. }
  112. public function getResultedInException(): bool
  113. {
  114. return $this->resultedInException;
  115. }
  116. /**
  117. * @var string|null
  118. *
  119. * @ORM\Column(name="exception_message", type="text", length=66560, nullable=true)
  120. */
  121. protected $exceptionMessage;
  122. public function setExceptionMessage(?string $exceptionMessage): void
  123. {
  124. if (!is_null($exceptionMessage)) {
  125. $this->exceptionMessage = mb_substr($exceptionMessage, 0, 4096);
  126. }
  127. }
  128. public function getExceptionMessage(): ?string
  129. {
  130. return $this->exceptionMessage;
  131. }
  132. /**
  133. * @var string
  134. *
  135. * @ORM\Column(name="request_method", type="string", length=32, nullable=false)
  136. */
  137. protected $requestmethod;
  138. public function setRequestmethod(string $requestmethod): void
  139. {
  140. $this->requestmethod = mb_substr($requestmethod, 0, 4096);
  141. }
  142. public function getRequestmethod(): string
  143. {
  144. return $this->requestmethod;
  145. }
  146. /**
  147. * @var string
  148. *
  149. * @ORM\Column(name="request_uri", type="string", length=4096, nullable=false)
  150. */
  151. protected $requestUri;
  152. public function setRequestUri(string $requestUri): void
  153. {
  154. $this->requestUri = mb_substr($requestUri, 0, 4096);
  155. }
  156. public function getRequestUri(): string
  157. {
  158. return $this->requestUri;
  159. }
  160. /**
  161. * @var string
  162. *
  163. * @ORM\Column(name="request_body", type="text", length=66560, nullable=false)
  164. */
  165. protected $requestBody;
  166. public function setRequestBody(string $requestBody): void
  167. {
  168. $this->requestBody = mb_substr($requestBody, 0, 16383);
  169. }
  170. public function getRequestBody(): string
  171. {
  172. return $this->requestBody;
  173. }
  174. /**
  175. * @var int
  176. *
  177. * @ORM\Column(name="http_response_status_code", type="smallint", nullable=false)
  178. */
  179. protected $httpResponseStatusCode;
  180. public function setHttpResponseStatusCode(int $httpResponseStatusCode): void
  181. {
  182. $this->httpResponseStatusCode = $httpResponseStatusCode;
  183. }
  184. public function getHttpResponseStatusCode(): int
  185. {
  186. return $this->httpResponseStatusCode;
  187. }
  188. /**
  189. * @var string|null
  190. *
  191. * @ORM\Column(name="response_body", type="text", length=66560, nullable=true)
  192. */
  193. protected $responseBody;
  194. public function setResponseBody(?string $responseBody): void
  195. {
  196. if (!is_null($responseBody)) {
  197. $this->responseBody = mb_substr($responseBody, 0, 66560);
  198. }
  199. }
  200. public function getResponseBody(): ?string
  201. {
  202. return $this->responseBody;
  203. }
  204. }