microserviciile de register, login finalizate

This commit is contained in:
Cerbu Andrei Mihnea
2023-06-15 22:21:53 +03:00
parent a739a66ae4
commit 4e585ba278
159 changed files with 4775 additions and 1747 deletions
+37
View File
@@ -0,0 +1,37 @@
<?php
namespace app\external_requests;
use app\exceptions\InvalidCurlStructureException;
class CurlRequestBuilder extends CurlRequest
{
private ?string $url = NULL;
private ?string $request = NULL;
private ?array $headers = NULL;
private ?array $body = NULL;
private bool $isReturnable = false;
public function __construct(){}
public function setUrl(?string $url): void{$this->url = $url;}
public function setHeaders(?array $headers): void{$this->headers = $headers;}
public function setRequest(?string $request): void{$this->request = $request;}
public function setBody(?array $body): void{$this->body = $body;}
public function setIsReturnable(?bool $isReturnable): void{$this->isReturnable = $isReturnable;}
private function areMainParametersNotSet(): bool{
return $this->url == NULL || $this->request == NULL || $this->headers == NULL;
}
/**
* @throws InvalidCurlStructureException
*/
public function getCurlRequestObject(): CurlRequest{
if($this->areMainParametersNotSet()){
throw new InvalidCurlStructureException("Invalid structure for making a request");
}
return new CurlRequest($this->url, $this->request, $this->headers, $this->body, $this->isReturnable);
}
}