src/Entity/Log/APIRequest.php line 12

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Log;
  3. use App\Repository\Log\APIRequestRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Timestampable\Traits\TimestampableEntity;
  6. /**
  7.  * @ORM\Entity(repositoryClass=APIRequestRepository::class)
  8.  */
  9. class APIRequest
  10. {
  11.     /**
  12.      * Hook timestampable behavior
  13.      * updates createdAt, updatedAt fields
  14.      */
  15.     use TimestampableEntity;
  16.     /**
  17.      * @ORM\Id
  18.      * @ORM\GeneratedValue
  19.      * @ORM\Column(type="integer")
  20.      */
  21.     private $id;
  22.     /**
  23.      * @var string
  24.      * @ORM\Column(type="string", length=10)
  25.      */
  26.     private $method;
  27.     /**
  28.      * @var string
  29.      * @ORM\Column(type="string", length=1024)
  30.      */
  31.     private $endPoint;
  32.     /**
  33.      * @var array|null
  34.      * @ORM\Column(type="json", nullable=true)
  35.      */
  36.     private $payload = [];
  37.     /**
  38.      * @var int
  39.      * @ORM\Column(type="integer", nullable=true)
  40.      */
  41.     private $statusCode;
  42.     /**
  43.      * @var array|null
  44.      * @ORM\Column(type="json", nullable=true)
  45.      */
  46.     private $responseInfos = [];
  47.     /**
  48.      * @var array|null
  49.      * @ORM\Column(type="json", nullable=true)
  50.      */
  51.     private $responseBody = [];
  52.     /**
  53.      * APIRequest constructor.
  54.      */
  55.     public function __construct()
  56.     {
  57.         $this->responseBody = ["status" => "waiting for response"];
  58.     }
  59.     /**
  60.      * @return string
  61.      */
  62.     public function getMethod(): string
  63.     {
  64.         return $this->method;
  65.     }
  66.     /**
  67.      * @param string $method
  68.      * @return APIRequest
  69.      */
  70.     public function setMethod(string $method): APIRequest
  71.     {
  72.         $this->method $method;
  73.         return $this;
  74.     }
  75.     /**
  76.      * @return string
  77.      */
  78.     public function getEndPoint(): string
  79.     {
  80.         return $this->endPoint;
  81.     }
  82.     /**
  83.      * @param string $endPoint
  84.      * @return APIRequest
  85.      */
  86.     public function setEndPoint(string $endPoint): APIRequest
  87.     {
  88.         $this->endPoint $endPoint;
  89.         return $this;
  90.     }
  91.     /**
  92.      * @return mixed
  93.      */
  94.     public function getId()
  95.     {
  96.         return $this->id;
  97.     }
  98.     /**
  99.      * @return array|null
  100.      */
  101.     public function getPayload(): ?array
  102.     {
  103.         return $this->payload;
  104.     }
  105.     /**
  106.      * @param array|null $payload
  107.      * @return APIRequest
  108.      */
  109.     public function setPayload(?array $payload): APIRequest
  110.     {
  111.         $this->payload $payload;
  112.         return $this;
  113.     }
  114.     /**
  115.      * @return int
  116.      */
  117.     public function getStatusCode(): int
  118.     {
  119.         return $this->statusCode;
  120.     }
  121.     /**
  122.      * @param int $statusCode
  123.      * @return APIRequest
  124.      */
  125.     public function setStatusCode(int $statusCode): APIRequest
  126.     {
  127.         $this->statusCode $statusCode;
  128.         return $this;
  129.     }
  130.     /**
  131.      * @return array|null
  132.      */
  133.     public function getResponseBody(): ?array
  134.     {
  135.         return $this->responseBody;
  136.     }
  137.     /**
  138.      * @param array|null $responseBody
  139.      * @return APIRequest
  140.      */
  141.     public function setResponseBody(?array $responseBody): APIRequest
  142.     {
  143.         $this->responseBody $responseBody;
  144.         return $this;
  145.     }
  146.     /**
  147.      * @return array|null
  148.      */
  149.     public function getResponseInfos(): ?array
  150.     {
  151.         return $this->responseInfos;
  152.     }
  153.     /**
  154.      * @param array|null $responseInfos
  155.      * @return APIRequest
  156.      */
  157.     public function setResponseInfos(?array $responseInfos): APIRequest
  158.     {
  159.         $this->responseInfos = isset($_ENV['APP_ENV']) && $_ENV['APP_ENV'] !== 'prod' $responseInfos : ["status" => 'Not logged in prod env'];
  160.         return $this;
  161.     }
  162. }