for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace seregazhuk\Favro\Api\Endpoints;
use seregazhuk\Favro\Contracts\HttpClient;
class Endpoint
{
/**
* @var array
*/
protected $allowedMethods = [
'getById',
'getAll',
'create',
'update',
'delete',
];
* @var string
protected $endpoint;
protected $headers = [];
* @var HttpClient
protected $http;
protected $organizationId;
* @param HttpClient $http
public function __construct(HttpClient $http)
$this->http = $http;
}
* @param string $verb
* @return string
public function makeRequestUrl($verb = '')
return "https://favro.com/api/v1/{$this->endpoint}/$verb";
* @param string $method
* @return bool
public function isMethodAllowed($method)
return in_array($method, $this->allowedMethods);
* @return HttpClient
public function getHttp()
return $this->http;
* @param array $params
* @return array
public function getAll(array $params = [])
return $this->getHttp()->get(
$this->makeRequestUrl(), $params, $this->getHeaders()
);
* @param string $id
public function getById($id)
$this->makeRequestUrl($id), [], $this->getHeaders()
protected function getHeaders()
return array_merge(
$this->headers,
['organizationId' => $this->organizationId]
* @param int $organizationId
* @return $this
public function setOrganizationId($organizationId)
$this->organizationId = $organizationId;
$organizationId
string
integer
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.
$answer = 42; $correct = false; $correct = (bool) $answer;
return $this;
This check looks for assignments to scalar types that may be of the wrong type.
To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.