| Total Complexity | 11 |
| Total Lines | 63 |
| Duplicated Lines | 0 % |
| Coverage | 86.36% |
| Changes | 0 | ||
| 1 | <?php |
||
| 15 | class QueryBuilder extends \hiqdev\hiart\AbstractQueryBuilder |
||
| 16 | { |
||
| 17 | protected $authHeaders = []; |
||
| 18 | |||
| 19 | /** |
||
| 20 | * This function is for you to provide your authentication. |
||
| 21 | * @param Query $query |
||
| 22 | */ |
||
| 23 | 2 | public function buildAuth(Query $query) |
|
| 24 | { |
||
| 25 | 2 | $auth = $this->db->getAuth(); |
|
| 26 | 2 | if (isset($auth['headerToken'])) { |
|
| 27 | 2 | $this->authHeaders['Authorization'] = 'token ' . $auth['headerToken']; |
|
| 28 | } |
||
| 29 | 2 | if (isset($auth['headerBearer'])) { |
|
| 30 | $this->authHeaders['Authorization'] = 'Bearer ' . $auth['headerBearer']; |
||
| 31 | } |
||
| 32 | 2 | } |
|
| 33 | |||
| 34 | 2 | public function buildMethod(Query $query) |
|
| 35 | { |
||
| 36 | 2 | static $defaultMethods = [ |
|
| 37 | 'get' => 'GET', |
||
| 38 | 'put' => 'PUT', |
||
| 39 | 'head' => 'HEAD', |
||
| 40 | 'post' => 'GET', |
||
| 41 | 'search' => 'GET', |
||
| 42 | 'insert' => 'POST', |
||
| 43 | 'update' => 'PUT', |
||
| 44 | 'delete' => 'DELETE', |
||
| 45 | ]; |
||
| 46 | |||
| 47 | 2 | return isset($defaultMethods[$query->action]) ? $defaultMethods[$query->action] : 'POST'; |
|
| 48 | } |
||
| 49 | |||
| 50 | public function buildUri(Query $query) |
||
| 51 | { |
||
| 52 | return $query->from; |
||
| 53 | } |
||
| 54 | |||
| 55 | 2 | public function buildHeaders(Query $query) |
|
| 58 | } |
||
| 59 | |||
| 60 | 2 | public function buildProtocolVersion(Query $query) |
|
| 61 | { |
||
| 62 | 2 | return null; |
|
| 63 | } |
||
| 64 | |||
| 65 | 2 | public function buildQueryParams(Query $query) |
|
| 68 | } |
||
| 69 | |||
| 70 | 2 | public function buildFormParams(Query $query) |
|
| 71 | { |
||
| 72 | 2 | return []; |
|
| 73 | } |
||
| 74 | |||
| 75 | 2 | public function buildBody(Query $query) |
|
| 78 | } |
||
| 79 | } |
||
| 80 |